void CopyZ( const COLLECTION& other ) { ULong _count = other.GetCount(); xassert(_count < _limit); Copy(other.GetMemory(), _count); _memory[_count] = 0; }
void Copy( const COLLECTION& other ) { xassert(other.GetCount() <= _limit); TYPE* i = _memory; for( COLLECTION::Iterator ci = other.Begin(); ci != other.End(); ci++, i++ ) *i = *ci; _count = other.GetCount(); }
Bool Compare( const COLLECTION& other ) const { if(other.GetCount() != _count) return false; else { Iterator i = Begin(), j = other.Begin(); for(; i != End() && *i == *j; i++, j++ ); return i == End(); } }
//---------------------------------------------------------------------------------------- /// Same as above but for any type of array. //---------------------------------------------------------------------------------------- template <typename COLLECTION> static void ArrayIterators(COLLECTION& array, const typename COLLECTION::ValueType a, const typename COLLECTION::ValueType b) { // Resize the array to contain 100 elements (elements are default-constructed). array.Resize(100); typename COLLECTION::Iterator it = array.Begin(); typename COLLECTION::Iterator start; typename COLLECTION::Iterator end; // The following two variables exist for debugging purposes only, hence the use of // UseVariable() to eliminate compiler warnings that indicate they are set but not used. Int cnt; Int distance; maxon::UseVariable(cnt); maxon::UseVariable(distance); // Assign a value to the element the iterator points to. *it = a; // Assign a value and go to the next element. *it++ = b; // Get the iterator to the first element. start = array.Begin(); // Get the iterator behind the last element. end = array.End(); // Get number of elements in the array (equivalent to array.GetCount()). cnt = start - end; // Calculate offset to the start. distance = it - start; // Advance by five elements. it += 5; // Use C++11 range based for loop (implicitly uses iterators). for (Int& element : array) element = a; // Manually use iterators to assign a value to all elements. end = array.End(); for (it = array.Begin(); it != end; ++it) *it = b; }