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.
Size capacity() const
Total capacity of container.
Iterator begin()
Iterator referencing to the first item.
VectorOverArray(Item *items, Size capacity)
Initializes instance over given fixed-size array.
ItemType Item
Aliases container item type.
Item * Iterator
Aliases mutable iterator type.
void erase(Size index)
Erases item at given position.
void throwVectorCopyOverflow(TargetSize targetSize, SourceSize sourceSize)
Iterator end()
Iterator referencing to the item behind the last item.
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Size size() const
Number of items.
Item & operator[](Size index)
Accesses to item by index.
const Item & at(Size index) const
Item & front()
Provides access to the front item if available.
ConstIterator begin() const
Iterator referencing to the first item.
Item & insertExtrude(Size index)
VectorOverArray()
Initializes instance with no items.
void resize(Size newSize, const Item &item=Item())
const Item & front() const
Provides access to the front item if available.
const Item * ConstIterator
Aliases constant iterator type.
ConstIterator end() const
Iterator referencing to the item behind the last item.
~VectorOverArray()
Cleans everything up.
void copy(VectorOverArray< TargetItem, TargetSize > &target, const VectorOverArray< SourceItem, TargetSize > &source, SourceSize itemCount=static_cast< SourceSize >(-1))
const Item & operator[](Size index) const
Accesses to item by index.
SizeType Size
Aliases dimension type.
ONIXS_CMEMDH_EXPORTED void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.
#define ONIXS_CMEMDH_NAMESPACE_END