Dillo v3.2.0-10-gc247d95a
|
Container, which is implemented by an array, which is dynamically resized. More...
#include <container.hh>
Classes | |
class | VectorIterator |
Public Member Functions | |
Vector (int initSize, bool ownerOfObjects) | |
~Vector () | |
int | size () |
void | put (object::Object *newElement, int newPos=-1) |
void | insert (object::Object *newElement, int pos) |
int | insertSorted (object::Object *newElement, object::Comparator *comparator=&object::standardComparator) |
Insert into an already sorted vector. | |
void | remove (int pos) |
object::Object * | get (int pos) const |
void | clear () |
void | sort (object::Comparator *comparator=&object::standardComparator) |
Sort the elements in the vector. | |
int | bsearch (Object *key, bool mustExist, int start, int end, object::Comparator *comparator=&object::standardComparator) |
Use binary search to find an element in a sorted vector. | |
int | bsearch (Object *key, bool mustExist, object::Comparator *comparator=&object::standardComparator) |
![]() | |
void | intoStringBuffer (misc::StringBuffer *sb) |
Store a textual representation of the object in a misc::StringBuffer. | |
Iterator | iterator () |
![]() | |
virtual | ~Object () |
The destructor is defined as virtual (but not abstract), so that destruction of Object's works properly. | |
virtual bool | equals (Object *other) |
Returns, whether two objects are equal. | |
virtual int | hashValue () |
Return a hash value for the object. | |
virtual Object * | clone () |
Return an exact copy of the object. | |
const char * | toString () |
Use object::Object::intoStringBuffer to return a textual representation of the object. | |
virtual size_t | sizeOf () |
Return the number of bytes, this object totally uses. | |
Protected Member Functions | |
AbstractIterator * | createIterator () |
Private Attributes | |
object::Object ** | array |
int | numAlloc |
int | numElements |
bool | ownerOfObjects |
Friends | |
class | VectorIterator |
Container, which is implemented by an array, which is dynamically resized.
Definition at line 124 of file container.hh.
lout::container::untyped::Vector::Vector | ( | int | initSize, |
bool | ownerOfObjects | ||
) |
Definition at line 105 of file container.cc.
References array, DBG_OBJ_CREATE, numAlloc, numElements, and ownerOfObjects.
lout::container::untyped::Vector::~Vector | ( | ) |
Definition at line 115 of file container.cc.
References array, clear(), and DBG_OBJ_DELETE.
int lout::container::untyped::Vector::bsearch | ( | Object * | key, |
bool | mustExist, | ||
int | start, | ||
int | end, | ||
object::Comparator * | comparator = &object::standardComparator |
||
) |
Use binary search to find an element in a sorted vector.
If "mustExist" is true, only exact matches are found; otherwise, -1 is returned. If it is false, the position of the next greater element is returned, or, if the key is the greatest element, the size of the array. (This is the value which can be used for insertion; see insertSortet()).
Definition at line 222 of file container.cc.
References array, lout::object::Comparator::compare(), DBG_OBJ_MSG, DBG_OBJ_MSG_END, DBG_OBJ_MSG_START, DBG_OBJ_MSGF, and size().
Referenced by bsearch(), and insertSorted().
|
inline |
Definition at line 176 of file container.hh.
void lout::container::untyped::Vector::clear | ( | ) |
Definition at line 159 of file container.cc.
References array, numElements, and ownerOfObjects.
Referenced by lout::container::untyped::List::~List(), and ~Vector().
|
protectedvirtual |
Implements lout::container::untyped::Collection0.
Definition at line 289 of file container.cc.
|
inline |
Definition at line 170 of file container.hh.
References array, and numElements.
void lout::container::untyped::Vector::insert | ( | object::Object * | newElement, |
int | pos | ||
) |
Definition at line 170 of file container.cc.
References array, numAlloc, numElements, and put().
Referenced by insertSorted().
|
inline |
Insert into an already sorted vector.
Notice that insertion is not very efficient, unless the position is rather at the end.
Definition at line 163 of file container.hh.
void lout::container::untyped::Vector::put | ( | object::Object * | newElement, |
int | newPos = -1 |
||
) |
Definition at line 128 of file container.cc.
References array, numAlloc, numElements, and ownerOfObjects.
Referenced by insert().
void lout::container::untyped::Vector::remove | ( | int | pos | ) |
Definition at line 193 of file container.cc.
References array, numElements, and ownerOfObjects.
|
virtual |
Implements lout::container::untyped::Collection.
Definition at line 123 of file container.cc.
References numElements.
void lout::container::untyped::Vector::sort | ( | object::Comparator * | comparator = &object::standardComparator | ) |
Sort the elements in the vector.
Assumes that all elements are Comparable's.
Definition at line 207 of file container.cc.
References array, lout::object::Comparator::compareFun(), lout::object::Comparator::compareFunComparator, and numElements.
|
friend |
Definition at line 126 of file container.hh.
|
private |
|
private |
Definition at line 130 of file container.hh.
|
private |
Definition at line 130 of file container.hh.
Referenced by lout::container::untyped::List::append(), clear(), lout::container::untyped::List::clear(), get(), lout::container::untyped::Vector::VectorIterator::getNext(), lout::container::untyped::HashSet::HashSet(), insert(), lout::container::untyped::List::insertBefore(), lout::container::untyped::HashSet::insertNode(), lout::container::untyped::List::List(), put(), remove(), lout::container::untyped::HashSet::remove(), lout::container::untyped::List::remove0(), size(), lout::container::untyped::List::size(), lout::container::untyped::HashSet::size(), sort(), and Vector().
|
private |
Definition at line 131 of file container.hh.
Referenced by clear(), lout::container::untyped::List::clear(), lout::container::untyped::HashSet::clearNode(), lout::container::untyped::HashSet::HashSet(), lout::container::untyped::List::List(), put(), remove(), lout::container::untyped::List::remove0(), Vector(), and lout::container::untyped::HashSet::~HashSet().