예제 #1
0
int makeSum(initializer_list<int> lst)
{
    int total = 0;
    for(auto iter = lst.begin(); iter!=lst.end(); ++iter)
	total += (*iter);
    return total;
}
	PointSequence(initializer_list<double> args)
	{
		if (args.size() % 2 != 0)
			throw invalid_argument("initializer_list should contain even number of elements.");
		for (auto iter = args.begin(); iter != args.end(); ++iter)
			mVecPoints.push_back(*iter);
	}
예제 #3
0
	Animation(int x, int y, initializer_list<char> chars, int speed = 5) : speed(speed), frame(1), counter(0)
	{
		Collision = true;
		Pos.Set(x, y);
		for(auto i = chars.begin(); i != chars.end(); ++i) frames.push_back(*i);
		Visual = frames[0];
	}
예제 #4
0
SparseVector::SparseVector(long size, long default_val, initializer_list<pair<long,long> > list)
{
    if (size < 0) {
        throw range_error("SparseVector size cannot be negative.");
    } else {
        fixed_size_ = size;
        unset_val_ = default_val;
    }      
    
    long count = 0;
    for (auto i = list.begin(); i != list.end(); i++) {
        
        if (i->first < (fixed_size_ - 1) && i->first >= 0) {
                      
            if (i->second != unset_val_) {
                data_[i->first] = data_[i->second];
            }
            
        } else {
            throw range_error("Cannot set value at an index greater than the size - 1 or less than 0.");
        }
        
        ++count;
    }
}
예제 #5
0
 Vector(initializer_list<T> list) : size{list.size()}
 {
     cout << "initializer list constructor" << endl;
     int i = 0;
     a.reset(new T[size]);
     for (auto iter = list.begin(); iter != list.end(); ++iter, ++i)
         a.get()[i] = *iter;
 }
예제 #6
0
int cal_sum(initializer_list<int> &list)
{
	int sum = 0;
	for (auto i = list.begin(); i != list.end(); ++i) {
		sum += *i;
	}
	return sum;
}
예제 #7
0
StrVec::StrVec(initializer_list<string> il)
{
	reallocate(il.size());
	auto p = begin_iter;
	for (auto beg = il.begin(); beg != il.end(); ++beg)
		alloc.construct(p++, *beg);
	end_iter = p;
}
예제 #8
0
int summation(initializer_list<int> val)
{
	int ret = 0;
	for (auto beg = val.begin(); beg != val.end(); ++beg)
	{
		ret += *beg;
	}
	return ret;
} 
예제 #9
0
Image::Image(int _rows,int _cols,initializer_list<float> _data):rows(_rows),cols(_cols){
	this->allocate();

	#if IMAGE_SAFE == 1
		assert(_data.size() == rows*cols);
	#endif

	std::copy(_data.begin(), _data.end(), data.get());
}
예제 #10
0
파일: Vector.cpp 프로젝트: 3A9C/ITstep
Vector::Vector(initializer_list<double> args)
{
	auto it = args.begin();
	element_count = args.size();
	memory_size = element_count * 2;
	vector = (double*)malloc(memory_size * sizeof(double));
	int i;
	for (it, i = 0; it != args.end(); it++, i++)
		vector[i] = *it;
}
예제 #11
0
	//local->world
	Matrix44 TransformHelper::CreateWorld(initializer_list<Matrix44> matrixOrder)
	{	//스케일, 자전, 이동, 공전, 부모 순으로 넣으면 된다.
		Matrix44 matWorld;
		for( auto iter = matrixOrder.begin(); iter != matrixOrder.end(); ++iter )
		{
			matWorld = (*iter) * matWorld;
		}

		return matWorld;
	}
예제 #12
0
파일: Army.cpp 프로젝트: Jakz/openmom
Army::Army(Player* owner, initializer_list<Unit*> units) : owner(owner), isPatrol(false), position(Position(-1, -1, ARCANUS)), route(nullptr)
{
    owner->add(this);

    for (auto u : units)
        add(u);

    if (units.begin() != units.end())
        updateMovementType();
}
예제 #13
0
TabelarnaFunkcija::TabelarnaFunkcija(initializer_list<pair<double, double>> lista)

{
    for(auto it = lista.begin(); it != lista.end(); it++) {
        for(auto it2 = it + 1; it2 != lista.end(); it2++) {
            if(it2->first == it->first) {
                throw domain_error("Ponavljanje istog x elementa.");
            }
        }
    }

    parovi = new pair<double, double>[lista.size()];
    max_broj_parova = lista.size();
    broj_dodanih_parova = lista.size();

    int cntr = 0;
    for(auto i : lista) {
        parovi[cntr] = i;
        cntr++;
    }

}
예제 #14
0
StrVec::StrVec(const initializer_list<string> &slist)
{
	size_t len = slist.size();
	auto newdata = alloc.allocate(len);
	auto dest = newdata;
	auto beg = slist.begin();
	while(beg != slist.end()){
		alloc.construct(dest++, std::move(*beg++));
	}
	
	elements = newdata;
	first_free = cap = dest;
}
예제 #15
0
    PointSequence(initializer_list<double> args)
    {
	cout << "size : " << args.size() << endl;
	if(args.size() % 2 != 0)
	{
	    throw invalid_argument("initializer_list should"
				   "contain even number of elements.");
	}

	for(auto iter = args.begin(); iter != args.end(); ++iter)
	{
	    mVecPoints.push_back(*iter);
	}
    }
예제 #16
0
void Transformation::setTransformations(int _num, initializer_list<string> st)
{
	numOfOperations = _num;

	left.insert(left.begin(), st.begin(), st.begin() + _num);
	right.insert(right.begin(), st.begin() + _num, st.end());

	for (size_t i = 0; i < numOfOperations; ++i)
	{
		if (right[i] == ".")
		{
			right[i] = "";
		}
	}
}
예제 #17
0
UInteger make_integer_impl(UInteger native, initializer_list<unsigned char> bytes)
{
	decltype(bytes)::const_iterator i = bytes.begin();
	if ( bytes.size() > sizeof(native) ) {
		i += bytes.size() - sizeof(native);
	}
	if ( sizeof(native) > 1 ) {
		for ( ; i != bytes.end(); ++i ) {
			native <<= CHAR_BIT;
			native |= *i;
		}
	}
	else {
		native = *i;
	}
	return native;
}
예제 #18
0
			//----------
			void Strip::setCellSizes(const initializer_list<int> & cellSizes) {
				this->programmaticCellSizes = vector<int>(cellSizes.begin(), cellSizes.end());
				this->resetUserCellSizes();
			}
예제 #19
0
 Vector(initializer_list<double> lst)
 :size{lst.size()}, elem{new double[size]}
 {
     copy(lst.begin(), lst.end(), elem);
 };
	// 2016.04.18,2016.04.20 add
	Point3Array(const initializer_list<Point>& args)
	{ assert(args.size() == 3);
	  uninitialized_copy(args.begin(), args.end(), elem); }
	// 2016.04.18 add
	array(const initializer_list<T>& args)
	{ uninitialized_copy(args.begin(), args.end(), elem); }
예제 #22
0
StrVec::StrVec(const initializer_list<string> &lst)
{
	auto newdata = alloc_n_copy(lst.begin(), lst.end());
	elements = newdata.first;
	first_free = cap = newdata.second;
}
예제 #23
0
StrVec::StrVec(initializer_list<string> il)
{
    range_initialize(il.begin(), il.end());
}
예제 #24
0
파일: message.hpp 프로젝트: alexz89ua/omim
template <typename T> inline string DebugPrint(initializer_list<T> const & v)
{
  return ::my::impl::DebugPrintSequence(v.begin(), v.end());
}
예제 #25
0
 A(initializer_list<int> n) {
   //for(auto i : n) v.push_back(i);
   for(auto i=n.begin(); i !=n.end(); ++i) v.push_back(*i);
 }
예제 #26
0
파일: Vertex.hpp 프로젝트: girdap/girdap
 // 01b RESET and replace connectivity; 
 void reset(initializer_list<int_8> l) {cell.assign(l.begin(), l.end());coefUpdate = true;}
예제 #27
0
	Sequence(const initializer_list<value_type>& ilist)
		: size(ilist.size())
	{
		data = new T[this->size];
		copy(ilist.begin(), ilist.end(), data);
	}
예제 #28
0
 inline reverse_iterator<const Ep*>
 rbegin(initializer_list<Ep> il)
 {
     return reverse_iterator<const Ep*>(il.end());
 }
예제 #29
0
bool command_line_parser::has(initializer_list<string> keys) const {
  return has(keys.begin(), keys.end());
}
예제 #30
0
optional<string> command_line_parser::pop(initializer_list<string> keys) {
  return pop(keys.begin(), keys.end());
}