#include <mpararr.h>
Inheritance diagram for Array::
Public Methods | |
Array (int siz=0) | |
void | make (int siz) |
void | isRef (bool isref) |
virtual | ~Array () |
void | empty () |
void | add (TYPE *i) |
void | add (const TYPE &i) |
void | put (TYPE *i, int loc) |
void | put (const TYPE &i, int loc) |
void | put (TYPE *p) |
const TYPE& | operator[] (int loc) const |
TYPE& | operator[] (int loc) |
const TYPE* | getp (int loc) const |
TYPE* | getp (int loc) |
int | find (const TYPE &item) const |
void | remove (int loc) |
void | removeFill (int loc) |
void | cut (int loc) |
void | resize (int newsize) |
void | operator= (const Array< TYPE > &other) |
virtual void | check () const |
void | quicksort () |
iterator | start () const |
Public Attributes | |
int | size |
Much better than manys other implementations.
Arrays can contain empty slots that do not point to an existing object. Some methods can also return NULL references to objects, which is rather special behaviour for C++ references. You can check the nullness of an object by the isnull(const Object&)-function in mobject.h.
if (isnull(myArray[5])) {...}
Definition at line 52 of file mpararr.h.
|
Creates an array of the given size with lower bound 0. If no size is given, creates an empty array. NOTE: The objects are not created with this constructor, but only when they are accessed first time. |
|
Destructor destroys all the objects contained by the Array.
|
|
Adds the given object to the end of the array; increments the size of the array by one. NOTE: Does not takes the ownership of the object, but just copies it using the copy constructor. |
|
Adds the given object to the end of the array; increments the size of the array by one. NOTE: Takes the ownership of the object. Definition at line 129 of file mpararr.h. Referenced by put(). |
|
Implementation for Object. Checks the integrity of the Array. Reimplemented from Object. |
|
Removes the object with the given index from the Array, but does NOT destruct the object; just removes the reference to it.
|
|
Destroys all the objects in the Array, but does NOT change the size.
Definition at line 115 of file mpararr.h. Referenced by make(), operator=(), MagiC::String::split(), and ~Array(). |
|
Finds the given object in the Array and returns it's index number, or -1 if not found.
|
|
Returns a pointer to the loc:th item in the Array. If the item does not exist, a NULL is returned. Throws 'assertion_failed' if the index is out of bounds. Non-const version. |
|
Returns a pointer to the loc:th item in the Array. If the item does not exist, a NULL is returned. Throws 'assertion_failed' if the index is out of bounds. Const version. |
|
Sets a flag that tells whether is not the objects inserted in this array are owned by the array or not. Thus, with value 'true', the class does not delete the objects, while with 'false' it does. The default for Array is 'false' (it owns the objects). NOTE: This feature entirely replaces the RefArray class. |
|
Creates an array of the given size with lower bound 0. If the array previously has any content, that content is destroyed. NOTE: The objects are not created with this method, but only when they are accessed first time. |
|
Standard =-operator. Performs deep copy. |
|
Returns a reference to the loc:th item in the Array. If the item does not exist (is null), it is created. Throws 'assertion_failed' if the index is out of bounds. Non-const version. |
|
Returns a reference to the loc:th item in the Array. If the item does not exist (is null), it is created. Throws 'assertion_failed' if the index is out of bounds. Const version. |
|
Adds the given object to any NULL location in the array; if no null locations exists, the object is added to the end of the array just like in add. NOTE: Takes the ownership of the object. |
|
Puts the given object to the given location. Old item in the same index location is destroyed. NOTE: Does not takes the ownership of the object, but just copies it using the copy constructor.
|
|
Puts the given object to the given location. Old item in the same index location is destroyed. NOTE: Takes the ownership of the object.
Definition at line 158 of file mpararr.h. Referenced by operator=(), and MagiC::String::split(). |
|
Sorts the values in the Array. NOTE: The contained objects MUST inherit Comparable, and be of the same class! |
|
Destroys the object with the given index number from the array. Does not fill the hole, but leaves it NULL. |
|
Destroys the object with the given index number from the Array, and fills the hole by shifting the rest of the items one index downwards.
|
|
Changes the bounds of the Array to the given ones. New size is calculated accordingly. Reserves or destructs as needed. Definition at line 307 of file mpararr.h. Referenced by add(), put(), and removeFill(). |
|
Size of the array. DO NOT MODIFY! This should be an access method, but is not. |