Esempio n. 1
0
typename fixedvector<T,kmax>::iterator_base::difference_type fixedvector<T,kmax>::const_iterator::operator - ( const const_iterator& oth ) const
{
	OrkAssert( mpfixedary );
	if( 0 != oth.mpfixedary )
	{
		OrkAssert( mpfixedary==oth.mpfixedary );
	}
	OrkAssert( oth.mdirection == this->mdirection );
	OrkAssert( this->mindex < int(mpfixedary->size()) );
	OrkAssert( oth.mindex < int(oth.mpfixedary->size()) );
	typename fixedvector<T,kmax>::iterator_base::difference_type defval = 0;
	if( this->mindex==npos )
	{
		iter_type icnt = iter_type(mpfixedary->size());
		defval = (icnt-oth.mindex);
		if( defval>icnt ) defval = icnt;
	}
	else if( oth.mindex==npos )
	{
		iter_type icnt = iter_type(mpfixedary->size());
		defval = (this->mindex-icnt);
	}
	else
	{
		defval = (this->mindex-oth.mindex);
	}
	return defval;
}
Esempio n. 2
0
const T* fixedvector<T,kmax>::const_iterator::operator ->() const
{
	OrkAssert( mpfixedary != 0 );
	iter_type isize = iter_type(mpfixedary->size());
	OrkAssert( this->mindex >= 0 );
	OrkAssert( this->mindex < isize );
	const typename fixedvector<T,kmax>::value_type* p0 = 
		(this->mdirection>0) ? & (*mpfixedary)[this->mindex] : & (*mpfixedary)[(isize-1)-this->mindex];
	return p0;
}
Esempio n. 3
0
typename fixedvector<T,kmax>::const_iterator fixedvector<T,kmax>::const_iterator::operator+=(intptr_t i) // add
{
	OrkAssert( mpfixedary );
	iter_type isize = iter_type(mpfixedary->size());
	this->mindex+=i;
	if( this->mindex >= isize )
	{
		this->mindex = npos;
	}
	return typename fixedvector<T,kmax>::const_iterator(*this);
}
Esempio n. 4
0
typename fixedvector<T,kmax>::iterator fixedvector<T,kmax>::iterator::operator++() // prefix
{
	OrkAssert( mpfixedary );
	iter_type isize = iter_type(mpfixedary->size());
	this->mindex++;
	if( this->mindex >= isize )
	{
		this->mindex = npos;
	}
	return typename fixedvector<T,kmax>::iterator(*this);
}
Esempio n. 5
0
typename fixedvector<T,kmax>::const_iterator fixedvector<T,kmax>::const_iterator::operator+(intptr_t i) const // add
{
	OrkAssert( mpfixedary );
	const_iterator temp( *this );
	iter_type isize = iter_type(temp.mpfixedary->size());
	temp.mindex+=i;
	if( temp.mindex >= isize )
	{
		temp.mindex = npos;
	}
	return temp;
}
Esempio n. 6
0
typename fixedvector<T,kmax>::const_iterator fixedvector<T,kmax>::const_iterator::operator++(int i) // postfix
{
	OrkAssert( mpfixedary );
	const_iterator temp( *this );
	iter_type isize = iter_type(mpfixedary->size());
	this->mindex++;
	if( this->mindex >= isize )
	{
		this->mindex = npos;
	}
	return temp;
}
Esempio n. 7
0
static void List_Assign(var self, var obj) {
    struct List* l = self;

    List_Clear(self);

    l->type = implements_method(obj, Iter, iter_type) ? iter_type(obj) : Ref;
    l->tsize = size(l->type);

    size_t nargs = len(obj);
    for (size_t i = 0; i < nargs; i++) {
        List_Push(self, get(obj, $I(i)));
    }

}
Esempio n. 8
0
typename fixedvector<T,kmax>::iterator fixedvector<T,kmax>::iterator::operator-=(intptr_t i) // sub
{
	OrkAssert( mpfixedary );
	iter_type isize = iter_type(mpfixedary->size());
	this->mindex-=i;
	if( this->mindex >= isize )
	{
		this->mindex = npos;
	}
	if( this->mindex < 0 )
	{
		this->mindex = npos;
	}
	return typename fixedvector<T,kmax>::iterator(*this);
}
Esempio n. 9
0
File: Array.c Progetto: 08opt/CPlus
static void Array_Assign(var self, var obj) {
  struct Array* a = self;

  Array_Clear(self);
  
  a->type = implements_method(obj, Iter, iter_type) ? iter_type(obj) : Ref;
  a->tsize = Array_Size_Round(size(a->type));
  a->nitems = 0;
  a->nslots = 0;
  
  if (implements_method(obj, Len, len)
  and implements_method(obj, Get, get)) {
  
    a->nitems = len(obj);
    a->nslots = a->nitems;
    
    if (a->nslots is 0) {
      a->data = NULL;
      return;
    }
    
    a->data = malloc(a->nslots * Array_Step(a));
    
  #if CELLO_MEMORY_CHECK == 1
    if (a->data is NULL) {
      throw(OutOfMemoryError, "Cannot allocate Array, out of memory!");
    }
  #endif
    
    for(size_t i = 0; i < a->nitems; i++) {
      Array_Alloc(a, i);
      assign(Array_Item(a, i), get(obj, $I(i)));  
    }
  
  } else {
    
    foreach (item in obj) {
      Array_Push(self, item);
    }
    
  }
Esempio n. 10
0
typename fixedvector<T,kmax>::iterator fixedvector<T,kmax>::iterator::operator-(intptr_t i) const// sub
{
	OrkAssert( mpfixedary );
	iterator temp( *this );
	iter_type isize = iter_type(mpfixedary->size());
	if( temp.mindex >= isize )
	{
		temp.mindex = npos;
	}
	else if( temp.mindex==npos && (i<=isize) )
	{
		temp.mindex = intptr_t(isize)-i;
	}
	else if( temp.mindex < 0 )
	{
		temp.mindex = npos;
	}
	else
	{
		temp.mindex-=i;
	}
	return temp;
}
Esempio n. 11
0
 iter_type get (iter_type, iter_type,
                std::ios_base&, std::ios_base::iostate&, ...) const {
     ++ellipsis_called;
     return iter_type ();
 }