118 return (items_ + size_);
125 return (items_ + size_);
151 assert(index < size_);
153 return items_[index];
161 assert(index < size_);
163 return items_[index];
173 return items_[index];
175 throw std::out_of_range
177 "Index outside of range." 188 return items_[index];
190 throw std::out_of_range
192 "Index outside of range." 206 assert(index < size_);
208 Item*
const toBeUpdated = items_ + index;
210 Item* target = items_ + size_ - 1;
211 Item* source = target - 1;
213 while (target != toBeUpdated)
217 new (target--) Item(*source--);
228 assert(index < size_);
230 Item*
const theEnd = end();
231 Item*
const toBeErased = items_ + index;
233 Item* target = toBeErased;
234 Item* source = toBeErased + 1;
236 while (source != theEnd)
240 new (target++) Item(*source++);
255 const Item& item = Item())
257 assert(newSize <= capacity_);
261 while (size_ != newSize)
262 new (items_ + size_++) Item(item);
266 while (size_ != newSize)
267 (items_ + --size_)->~Item();
275 const Size capacity_;
293 TargetSize targetSize,
294 SourceSize sourceSize)
299 "Cannot copy items because number " 300 "of source items exceeds target capacity " 303 toStr(error, sourceSize);
305 error +=
",targetCapacity=";
307 toStr(error, targetSize);
311 throw std::runtime_error(error);
327 <TargetItem, TargetSize>&
331 <SourceItem, TargetSize>&
333 SourceSize itemCount =
334 static_cast<SourceSize>(-1))
336 if (itemCount > source.size())
337 itemCount = source.size();
339 if (itemCount > target.capacity())
348 target.resize(itemCount);
bool empty() const
Indicates whether instance has no items.
VectorOverArray(Item *items, Size capacity)
Initializes instance over given fixed-size array.
VectorOverArray()
Initializes instance with no items.
const Item & operator[](Size index) const
Accesses to item by index.
ItemType Item
Aliases container item type.
Size size() const
Number of items.
Size capacity() const
Total capacity of container.
Item * Iterator
Aliases mutable iterator type.
Item & front()
Provides access to the front item if available.
Iterator begin()
Iterator referencing to the first item.
const Item & front() const
Provides access to the front item if available.
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_END
void resize(Size newSize, const Item &item=Item())
Resizes container.
SizeType Size
Aliases dimension type.
ConstIterator end() const
Iterator referencing to the item behind the last item.
void toStr(std::string &str, const Decimal &number)
void copy(VectorOverArray< TargetItem, TargetSize > &target, const VectorOverArray< SourceItem, TargetSize > &source, SourceSize itemCount=static_cast< SourceSize >(-1))
Copies items from source to target.
ConstIterator begin() const
Iterator referencing to the first item.
const Item & at(Size index) const
Accesses to item by index checking access bounds.
#define ONIXS_CMESTREAMLINEDMDH_NULLPTR
Item & insertExtrude(Size index)
Inserts new item to given position.
Iterator end()
Iterator referencing to the item behind the last item.
~VectorOverArray()
Cleans everything up.
Item & at(Size index)
Accesses to item by index checking access bounds.
const Item * ConstIterator
Aliases constant iterator type.
void erase(Size index)
Erases item at given position.
void throwVectorCopyOverflow(TargetSize targetSize, SourceSize sourceSize)
Implements vector-like container over built-in array of fixed size being referenced.
Item & operator[](Size index)
Accesses to item by index.
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_BEGIN