![]() |
Gorgon Game Engine
|
Collection is a container for reference typed objects. More...
Classes | |
class | ConstIterator |
Const iterator allows iteration of const collections. More... | |
Public Types | |
typedef Iterator_< T_, Collection > | Iterator |
Regular iterator. More... | |
Public Member Functions | |
Collection ()=default | |
Default constructor. More... | |
Collection (Collection &&col) | |
Move constructor. More... | |
Collection (const Collection &)=delete | |
Disabled. More... | |
template<typename... Args_> | |
Collection (T_ &t, Args_ &... args) | |
Initializing constructor. More... | |
template<typename... Args_> | |
Collection (T_ *t, Args_ *... args) | |
Initializing constructor. More... | |
bool | Add (T_ &data) |
Adds a the given item to the end of the list if it is not already in the list. More... | |
template<typename... Args_> | |
int | Add (T_ &data, Args_ &... args) |
Adds a the given item to the end of the list. More... | |
bool | Add (T_ *Data) |
Adds the given item to the end of the list if it is not already in the list. More... | |
template<typename... Args_> | |
int | Add (T_ *Data, Args_ *... args) |
Adds the given item to the end of the list, returns the number of added elements. More... | |
template<typename... Args_> | |
T_ & | AddNew (Args_ &&... args) |
Creates a new item and adds to the end of the collection. More... | |
void | Clear () |
Removes all items from the list, allocated memory for the list stays. More... | |
void | Collapse () |
Clears the contents of the collection and releases the memory used for the list. More... | |
void | Delete (const T_ *item) |
Deletes an item from the collection using its pointer. More... | |
void | Delete (ConstIterator &it) |
void | Delete (Iterator &it) |
void | Delete (long index) |
Deletes an item from the collection using its index. More... | |
void | Delete (T_ &data) |
Deletes an item from the collection using its reference. More... | |
void | DeleteAll () |
Deletes and removes all elements in the collection. More... | |
void | Destroy () |
Destroys the entire collection, effectively deleting the contents and the list including all the memory used by it. More... | |
Collection | Duplicate () const |
Duplicates this collection. More... | |
Iterator | Find (const T_ &item) |
Searches the position of a given item, if not found end iterator returned. More... | |
ConstIterator | Find (const T_ &item) const |
Searches the position of a given item, if not found end iterator returned. More... | |
Iterator | Find (const T_ *item) |
Searches the position of a given item, if not found end iterator returned. More... | |
ConstIterator | Find (const T_ *item) const |
Searches the position of a given item, if not found end iterator returned. More... | |
long | FindLocation (const T_ &item) const |
Searches the position of a given item, if not found -1 is returned. More... | |
long | FindLocation (const T_ *item) const |
Searches the position of a given item, if not found -1 is returned. More... | |
T_ & | Get (long index) |
Returns the element at the given index. Checks and throws if out of range. More... | |
T_ & | Get (long index) const |
Returns the element at the given index. Checks and throws if out of range. More... | |
long | GetCount () const |
Returns number of elements. More... | |
long | GetSize () const |
Returns number of elements. More... | |
bool | Insert (T_ &data, const T_ &before) |
this method adds the given object in front of the reference. More... | |
bool | Insert (T_ &data, long before) |
this method adds the given object in front of the reference. More... | |
bool | Insert (T_ *data, const T_ &before) |
this method adds the given object in front of the reference. More... | |
bool | Insert (T_ *data, long before) |
this method adds the given object in front of the reference. More... | |
template<typename... Args_> | |
T_ & | InsertNew (const T_ &before, Args_... args) |
Creates a new item and inserts it before the given reference. More... | |
template<typename... Args_> | |
T_ & | InsertNew (long before, Args_... args) |
Creates a new item and inserts it before the given reference. More... | |
void | MoveBefore (const T_ &index, const T_ &before) |
this method moves the given object in the collection in front of the reference More... | |
void | MoveBefore (const T_ &index, long before) |
this method moves the given object in the collection in front of the reference More... | |
void | MoveBefore (long index, const T_ &before) |
this method moves the given object in the collection in front of the reference More... | |
void | MoveBefore (long index, long before) |
this method moves the given object in the collection in front of the reference More... | |
Adder | operator+= (T_ &data) |
Adds items to the end of the list. Use comma to add more than one item. More... | |
Adder | operator+= (T_ *Data) |
Adds items to the end of the list. Use comma to add more than one item. More... | |
Collection & | operator= (Collection &&col) |
Move assignment. More... | |
Collection & | operator= (const Collection &)=delete |
Disabled. More... | |
T_ & | operator[] (long index) |
Returns the item at a given index. More... | |
T_ & | operator[] (long index) const |
Returns the item at a given index. More... | |
T_ & | Pop () |
Removes and returns the last item in the collection. More... | |
bool | Push (T_ &data) |
Adds a the given item to the end of the list if it is not already in the list. More... | |
bool | Push (T_ *Data) |
Adds the given item to the end of the list if it is not already in the list. More... | |
void | Remove (const T_ &data) |
Removes an item from the collection using its reference. More... | |
void | Remove (const T_ *item) |
Removes an item from the collection using its pointer. More... | |
void | Remove (ConstIterator &it) |
void | Remove (Iterator &it) |
void | Remove (long index) |
Removes an item from the collection using its index. More... | |
void | Reserve (long amount) |
Allocates memory for the given amount of items. More... | |
void | Sort () |
Sorts items in the collection. More... | |
template<class P_ > | |
void | Sort (P_ predicate=P_()) |
Sorts items in the collection. More... | |
void | Swap (Collection &col) |
Swaps the given collection with this one. More... | |
Iterator related | |
Iterator | begin () |
Iterator | end () |
end iterator More... | |
Iterator | First () |
returns the iterator to the first item More... | |
Iterator | Last () |
returns the iterator to the last item More... | |
ConstIterator | begin () const |
begin iterator More... | |
ConstIterator | end () const |
end iterator More... | |
ConstIterator | First () const |
returns the iterator to the first item More... | |
ConstIterator | Last () const |
returns the iterator to the last item More... | |
Collection is a container for reference typed objects.
A container never copies its elements nor destroys unless requested specifically. Internally, a collection stores its objects in a vector as pointers. This class supports move semantics. Also copying of a collection is disabled for performance reasons. Use Duplicate method to create a duplicate of a collection.
typedef Iterator_<T_, Collection> Iterator |
Regular iterator.
|
default |
Default constructor.
Collection | ( | T_ & | t, |
Args_ &... | args | ||
) |
Initializing constructor.
Collection | ( | T_ * | t, |
Args_ *... | args | ||
) |
Initializing constructor.
|
delete |
Disabled.
Collection | ( | Collection< T_ > && | col | ) |
Move constructor.
bool Add | ( | T_ & | data | ) |
Adds a the given item to the end of the list if it is not already in the list.
int Add | ( | T_ & | data, |
Args_ &... | args | ||
) |
Adds a the given item to the end of the list.
bool Add | ( | T_ * | Data | ) |
Adds the given item to the end of the list if it is not already in the list.
int Add | ( | T_ * | Data, |
Args_ *... | args | ||
) |
Adds the given item to the end of the list, returns the number of added elements.
T_& AddNew | ( | Args_ &&... | args | ) |
Creates a new item and adds to the end of the collection.
Iterator begin | ( | ) |
ConstIterator begin | ( | ) | const |
begin iterator
void Clear | ( | ) |
Removes all items from the list, allocated memory for the list stays.
void Collapse | ( | ) |
Clears the contents of the collection and releases the memory used for the list.
Items are not freed.
void Delete | ( | const T_ * | item | ) |
Deletes an item from the collection using its pointer.
Deleting both removes the item from the list and free the item itself. If given item does not exists, this function deletes the item and does nothing else
void Delete | ( | ConstIterator & | it | ) |
void Delete | ( | Iterator & | it | ) |
void Delete | ( | long | index | ) |
Deletes an item from the collection using its index.
Deleting both removes the item from the list and free the item itself.
void Delete | ( | T_ & | data | ) |
Deletes an item from the collection using its reference.
Deleting both removes the item from the list and free the item itself. If given item does not exists, this function deletes the item and does nothing else
void DeleteAll | ( | ) |
Deletes and removes all elements in the collection.
void Destroy | ( | ) |
Destroys the entire collection, effectively deleting the contents and the list including all the memory used by it.
Collection Duplicate | ( | ) | const |
Duplicates this collection.
Copy constructor is disabled for performance reasons. Therefore, this function is necessary to duplicate a collection
Iterator end | ( | ) |
end iterator
ConstIterator end | ( | ) | const |
end iterator
Iterator Find | ( | const T_ & | item | ) |
Searches the position of a given item, if not found end iterator returned.
ConstIterator Find | ( | const T_ & | item | ) | const |
Searches the position of a given item, if not found end iterator returned.
Iterator Find | ( | const T_ * | item | ) |
Searches the position of a given item, if not found end iterator returned.
ConstIterator Find | ( | const T_ * | item | ) | const |
Searches the position of a given item, if not found end iterator returned.
long FindLocation | ( | const T_ & | item | ) | const |
Searches the position of a given item, if not found -1 is returned.
long FindLocation | ( | const T_ * | item | ) | const |
Searches the position of a given item, if not found -1 is returned.
Iterator First | ( | ) |
returns the iterator to the first item
ConstIterator First | ( | ) | const |
returns the iterator to the first item
T_& Get | ( | long | index | ) |
Returns the element at the given index. Checks and throws if out of range.
T_& Get | ( | long | index | ) | const |
Returns the element at the given index. Checks and throws if out of range.
long GetCount | ( | ) | const |
Returns number of elements.
long GetSize | ( | ) | const |
Returns number of elements.
bool Insert | ( | T_ & | data, |
const T_ & | before | ||
) |
this method adds the given object in front of the reference.
You may use the size of the collection for this function to behave like Add.
bool Insert | ( | T_ & | data, |
long | before | ||
) |
this method adds the given object in front of the reference.
You may use the size of the collection for this function to behave like Add.
bool Insert | ( | T_ * | data, |
const T_ & | before | ||
) |
this method adds the given object in front of the reference.
You may use the size of the collection for this function to behave like Add.
bool Insert | ( | T_ * | data, |
long | before | ||
) |
this method adds the given object in front of the reference.
You may use the size of the collection for this function to behave like Add.
T_& InsertNew | ( | const T_ & | before, |
Args_... | args | ||
) |
Creates a new item and inserts it before the given reference.
You may use the size of the collection for this function to behave like Add.
T_& InsertNew | ( | long | before, |
Args_... | args | ||
) |
Creates a new item and inserts it before the given reference.
You may use the size of the collection for this function to behave like Add.
Iterator Last | ( | ) |
returns the iterator to the last item
ConstIterator Last | ( | ) | const |
returns the iterator to the last item
void MoveBefore | ( | const T_ & | index, |
const T_ & | before | ||
) |
this method moves the given object in the collection in front of the reference
void MoveBefore | ( | const T_ & | index, |
long | before | ||
) |
this method moves the given object in the collection in front of the reference
void MoveBefore | ( | long | index, |
const T_ & | before | ||
) |
this method moves the given object in the collection in front of the reference
void MoveBefore | ( | long | index, |
long | before | ||
) |
this method moves the given object in the collection in front of the reference
Adder operator+= | ( | T_ & | data | ) |
Adds items to the end of the list. Use comma to add more than one item.
Adder operator+= | ( | T_ * | Data | ) |
Adds items to the end of the list. Use comma to add more than one item.
Collection& operator= | ( | Collection< T_ > && | col | ) |
Move assignment.
|
delete |
Disabled.
T_& operator[] | ( | long | index | ) |
Returns the item at a given index.
T_& operator[] | ( | long | index | ) | const |
Returns the item at a given index.
T_& Pop | ( | ) |
Removes and returns the last item in the collection.
bool Push | ( | T_ & | data | ) |
Adds a the given item to the end of the list if it is not already in the list.
bool Push | ( | T_ * | Data | ) |
Adds the given item to the end of the list if it is not already in the list.
void Remove | ( | const T_ & | data | ) |
Removes an item from the collection using its reference.
If the item does not exists, nothing is done.
void Remove | ( | const T_ * | item | ) |
Removes an item from the collection using its pointer.
If the item does not exists, nothing is done.
void Remove | ( | ConstIterator & | it | ) |
void Remove | ( | Iterator & | it | ) |
void Remove | ( | long | index | ) |
Removes an item from the collection using its index.
void Reserve | ( | long | amount | ) |
Allocates memory for the given amount of items.
void Sort | ( | ) |
Sorts items in the collection.
Regular std::sort cannot work on collections as assignment will copy objects
void Sort | ( | P_ | predicate = P_() | ) |
Sorts items in the collection.
Regular std::sort cannot work on collections as assignment will copy objects
void Swap | ( | Collection< T_ > & | col | ) |
Swaps the given collection with this one.