Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/vis15/src/lib/include/diderot/dynseq-inst.hxx
ViewVC logotype

View of /branches/vis15/src/lib/include/diderot/dynseq-inst.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3987 - (download) (as text) (annotate)
Fri Jun 17 03:08:25 2016 UTC (3 years ago) by jhr
File size: 1709 byte(s)
working on merge: runtime
/*! \file dynseq-inst.hxx
 *
 * \author John Reppy
 */

/*
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2016 The University of Chicago
 * All rights reserved.
 */

#ifndef _DIDEROT_DYNSEQ_INST_HXX_
#define _DIDEROT_DYNSEQ_INST_HXX_


#ifndef _DIDEROT_DYNSEQ_HXX_
# error dynseq-inst.hxx should not be directly included
#endif

#include "nrrd-inst.hxx"

namespace diderot {

  //! construct a sequence from a nrrd
    template <typename T>
    dynseq<T>::dynseq (const Nrrd *nin)
	: _seq(std::make_shared<std::vector<T>>(std::vector<T>()))
    {
// FIXME
    }

  //! construct a sequence for a range lo..hi (integer types only)
    template <typename T>
    dynseq<T>::dynseq (T const &lo, T const &hi)
	: _seq(std::make_shared<std::vector<T>>(std::vector<T>()))
    {
	if (lo <= hi) {
	    this->_seq->reserve (hi - lo + 1);
	    for (T i = lo;  i <= hi;  ++i) {
		this->_seq->push_back(i);
	    }
	}
    }

  //! copy constructor with additional space reserved
    template <typename T>
    dynseq<T>::dynseq (const dynseq &seq, uint32_t n)
    {
    }

    template <typename T>
    dynseq<T> &dynseq<T>::prepend (T const &x)
    {
	this->_seq->insert (this->_seq->begin(), x);
	return *this;
    }

    template <typename T>
    dynseq<T> &dynseq<T>::append (T const &x)
    {
	this->_seq->push_back(x);
	return *this;
    }

    template <typename T>
    dynseq<T> &dynseq<T>::concat (dynseq<T> const &seq)
    {
	this->_seq->reserve (this->length() + seq.length());
	for (auto it = seq.cbegin(); it != seq.cend(); ++it) {
	    this->_seq->push_back (*it);
	}
	return *this;
    }

} // namespace diderot

#endif // !_DIDEROT_DYNSEQ_INST_HXX_

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0