1 #ifndef __LOUT_CONTAINER_HH_
2 #define __LOUT_CONTAINER_HH_
51 void ref () { refcount++; }
52 void unref () { refcount--;
if (refcount == 0)
delete this; }
96 virtual int size() = 0;
129 Vector(
int initSize,
bool ownerOfObjects);
146 {
int pos =
bsearch (newElement,
false, comparator);
147 insert (newElement, pos);
return pos; }
149 void remove(
int pos);
151 {
return (pos >= 0 && pos < numElements) ? array[pos] : NULL; }
159 {
return bsearch (key, mustExist, 0,
size () - 1, comparator); }
198 List(
bool ownerOfObjects);
210 {
return remove0(element,
false,
false); }
212 {
return remove0(element,
true,
false); }
214 {
return remove0(element,
false,
true); }
216 inline bool isEmpty()
const {
return numElements == 0; }
242 return abs(object->
hashValue()) % tableSize;
270 HashSet(
bool ownerOfObjects,
int tableSize = 251);
345 Stack (
bool ownerOfObjects);
386 { this->base = it2.
base;
return *
this; }
388 { this->base = it2.
base;
return *
this; }
428 inline Vector(
int initSize,
bool ownerOfObjects) {
431 inline void put(T *newElement,
int newPos = -1)
433 inline void insert(T *newElement,
int pos)
441 inline T *
get(
int pos)
const
447 inline int bsearch(T *key,
bool mustExist,
int start,
int end,
466 inline List(
bool ownerOfObjects)
476 inline bool remove(T *element) {
498 inline HashSet(
bool owner,
int tableSize = 251)
501 inline void put(T *
object)
505 inline bool remove(T *object)
517 inline HashTable(
bool ownerOfKeys,
bool ownerOfValues,
int tableSize = 251)
521 inline void put(K *key, V *value)
523 inline V *
get(K *key)
const
551 #endif // __LOUT_CONTAINER_HH_
void insert(object::Object *newElement, int pos)
Definition: container.cc:167
int size() const
Definition: container.hh:354
Stack::Node * current
Definition: container.hh:330
~Iterator()
Definition: container.hh:384
HashSet(bool owner, int tableSize=251)
Definition: container.hh:498
int calcHashValue(object::Object *object) const
Definition: container.hh:240
Definition: container.hh:171
Iterator & operator=(Iterator< T > &it2)
Definition: container.hh:387
bool isEmpty() const
Definition: container.hh:481
Typed version of container::untyped::Vector.
Definition: container.hh:425
void pop()
Definition: container.cc:761
void ref()
Definition: container.hh:51
Node * top
Definition: container.hh:337
virtual bool equals(Object *other)
Returns, whether two objects are equal.
Definition: object.cc:50
int index
Definition: container.hh:117
virtual Object * getNext()=0
A class for fast concatenation of a large number of strings.
Definition: misc.hh:565
VectorIterator(Vector *vector)
Definition: container.hh:120
bool equals(Object *other)
Returns, whether two objects are equal.
Definition: container.cc:309
void push(object::Object *object)
Definition: container.cc:733
Definition: container.hh:289
object::Object * object
Definition: container.hh:323
Collection()
Definition: container.hh:406
Typed version of container::untyped::HashTable.
Definition: container.hh:514
int insertSorted(T *newElement, object::Comparator *comparator=&object::standardComparator)
Definition: container.hh:435
untyped::Iterator base
Definition: container.hh:378
HashTable(bool ownerOfKeys, bool ownerOfValues, int tableSize=251)
Definition: container.cc:631
bool ownerOfObjects
Definition: container.hh:111
Typed version of container::untyped::Stack.
Definition: container.hh:530
int size()
Definition: container.cc:123
Node * createNode()
Definition: container.cc:653
Node * insertNode(object::Object *object)
Definition: container.cc:506
...
Definition: container.hh:34
HashSet(bool ownerOfObjects, int tableSize=251)
Definition: container.cc:440
void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition: container.cc:670
Definition: container.hh:327
object::Object * getFirst() const
Definition: container.hh:217
Definition: container.hh:320
bool isEmpty() const
Definition: container.hh:216
int size()
Definition: container.cc:477
bool removeRef(T *element)
Definition: container.hh:474
This is the base class for many other classes, which defines very common virtual methods.
Definition: object.hh:24
Node ** table
Definition: container.hh:236
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.
Definition: container.cc:216
int numElements
Definition: container.hh:110
HashSet()
Definition: container.hh:495
int size()
Definition: container.hh:418
Collection0::AbstractIterator * impl
Definition: container.hh:71
int size()
Definition: container.cc:304
void clear()
Definition: container.cc:330
Iterator(const Iterator< T > &it2)
Definition: container.hh:382
int bsearch(Object *key, bool mustExist, object::Comparator *comparator=&object::standardComparator)
Definition: container.hh:156
The base class for all iterators, as created by container::untyped::Collection::createIterator.
Definition: container.hh:43
void gotoNext()
Definition: container.cc:591
Abstract base class for all container objects in container::untyped.
Definition: container.hh:91
T * getLast() const
Definition: container.hh:485
Used for other orders as the one defined by Comparable.
Definition: object.hh:66
void put(T *newElement, int newPos=-1)
Definition: container.hh:431
int insertSorted(object::Object *newElement, object::Comparator *comparator=&object::standardComparator)
Insert into an already sorted vector.
Definition: container.hh:143
Iterator(Collection0::AbstractIterator *impl)
Definition: container.hh:74
Iterator< T > iterator()
Definition: container.hh:416
int numElements
Definition: container.hh:190
~List()
Definition: container.cc:299
void put(T *object)
Definition: container.hh:501
bool insertBefore(object::Object *beforeThis, object::Object *neew)
Definition: container.hh:472
bool detachRef(object::Object *element)
Definition: container.hh:213
StackIterator(Stack::Node *node)
Definition: container.hh:332
AbstractIterator * createIterator()
Definition: container.cc:283
Container, which is implemented by an array, which is dynamically resized.
Definition: container.hh:104
object::Object * getLast() const
Definition: container.hh:218
bool ownerOfObjects
Definition: container.hh:238
int tableSize
Definition: container.hh:237
Iterator()
Definition: container.cc:39
~Collection()
Definition: container.hh:407
HashSet::Node * node
Definition: container.hh:258
AbstractIterator * createIterator()
Definition: container.cc:430
Object * getNext()
Definition: container.cc:270
Iterator()
Definition: container.hh:381
int bsearch(T *key, bool mustExist, int start, int end, object::Comparator *comparator=&object::standardComparator)
Definition: container.hh:447
~Vector()
Definition: container.cc:115
object::Object * object
Definition: container.hh:174
Node * next
Definition: container.hh:175
int bsearch(T *key, bool mustExist, object::Comparator *comparator=&object::standardComparator)
Definition: container.hh:452
void sort(object::Comparator *comparator=&object::standardComparator)
Definition: container.hh:444
Object * getNext()
Definition: container.cc:412
Typed version of container::untyped::HashSet.
Definition: container.hh:492
void clear()
Definition: container.hh:443
void unref()
Definition: container.hh:52
Definition: container.hh:230
Node * first
Definition: container.hh:188
Vector(int initSize, bool ownerOfObjects)
Definition: container.cc:105
int pos
Definition: container.hh:259
int hashValue()
Return a hash value for the object.
Definition: container.cc:322
Definition: container.hh:178
void pushUnder(T *object)
Definition: container.hh:538
Vector(int initSize, bool ownerOfObjects)
Definition: container.hh:428
bool detachRef(T *element)
Definition: container.hh:478
Object * getNext()
Definition: container.cc:776
virtual void clearNode(Node *node)
Definition: container.cc:487
~HashTable()
Definition: container.cc:637
int hashValue()
Return a hash value for the object.
Definition: container.hh:412
Definition: container.hh:113
void clear()
Definition: container.cc:156
AbstractIterator * createIterator()
Definition: container.cc:794
void push(T *object)
Definition: container.hh:536
A hash set.
Definition: container.hh:225
Abstract base class template for all container objects in container::typed.
Definition: container.hh:368
void put(K *key, V *value)
Definition: container.hh:521
object::Object * getNext()
Definition: container.hh:85
~Stack()
Definition: container.cc:722
int size()
Definition: container.cc:728
List(bool ownerOfObjects)
Definition: container.hh:466
Definition: container.cc:27
Node * findNode(object::Object *object) const
Definition: container.cc:495
Vector * vector
Definition: container.hh:116
object::Object * getTop() const
Definition: container.hh:352
Node * bottom
Definition: container.hh:337
bool ownerOfObjects
Definition: container.hh:338
void put(object::Object *object)
Definition: container.cc:526
T * getTop() const
Definition: container.hh:540
AbstractIterator()
Definition: container.hh:49
HashSet * set
Definition: container.hh:257
bool remove0(object::Object *element, bool compare, bool doNotDeleteAtAll)
Definition: container.cc:382
virtual int hashValue()
Return a hash value for the object.
Definition: object.cc:59
object::Object ** array
Definition: container.hh:109
Iterator(Iterator< T > &it2)
Definition: container.hh:383
void append(object::Object *element)
Definition: container.cc:344
StandardComparator standardComparator
Definition: object.cc:148
HashSetIterator(HashSet *set)
Definition: container.cc:583
bool ownerOfValues
Definition: container.hh:287
bool hasNext()
Definition: container.hh:390
T * getNext()
Definition: container.hh:391
T * getFirst() const
Definition: container.hh:483
Node * last
Definition: container.hh:188
bool hasNext()
Definition: container.cc:278
Object * getNext()
Definition: container.cc:605
untyped::Collection * base
Definition: container.hh:403
bool hasNext()
Definition: container.cc:617
Iterator & operator=(const Iterator &it2)
Definition: container.cc:58
ListIterator(List::Node *node)
Definition: container.hh:183
void sort(object::Comparator *comparator=&object::standardComparator)
Definition: container.cc:201
void append(T *element)
Definition: container.hh:470
int numElements
Definition: container.hh:339
A single-linked list.
Definition: container.hh:166
int refcount
Definition: container.hh:46
List(bool ownerOfObjects)
Definition: container.cc:292
Stack(bool ownerOfObjects)
Definition: container.hh:533
Node * prev
Definition: container.hh:324
void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition: container.cc:88
AbstractIterator * createIterator()
Definition: container.cc:622
bool hasNext()
Definition: container.cc:425
virtual AbstractIterator * createIterator()=0
Node * next
Definition: container.hh:233
HashTable(bool ownerOfKeys, bool ownerOfValues, int tableSize=251)
Definition: container.hh:517
void put(object::Object *newElement, int newPos=-1)
Definition: container.cc:128
Iterator & operator=(const Iterator< T > &it2)
Definition: container.hh:385
Iterator iterator()
Definition: container.hh:95
void insert(T *newElement, int pos)
Definition: container.hh:433
void clearNode(Node *node)
Definition: container.cc:658
bool contains(T *object) const
Definition: container.hh:503
A stack (LIFO). Can be used as Queue (FIFO) when pushUnder() is used instead of push().
Definition: container.hh:315
bool ownerOfObjects
Definition: container.hh:189
void pushUnder(object::Object *object)
Definition: container.cc:746
Definition: container.hh:254
int numElements
Definition: container.hh:237
int numAlloc
Definition: container.hh:110
virtual Node * createNode()
Definition: container.cc:482
Typed version of container::untyped::Iterator.
Definition: container.hh:373
This is a small wrapper for AbstractIterator, which may be used directly, not as a pointer...
Definition: container.hh:66
bool equals(Object *other)
Returns, whether two objects are equal.
Definition: container.hh:409
bool hasNext()
Definition: container.hh:84
void clear()
Definition: container.hh:469
~Iterator()
Definition: container.cc:78
~HashSet()
Definition: container.cc:452
bool insertBefore(object::Object *beforeThis, object::Object *neew)
Definition: container.cc:359
bool contains(object::Object *key) const
Definition: container.cc:531
void pop()
Definition: container.hh:542
A hash table.
Definition: container.hh:284
bool removeRef(object::Object *element)
Definition: container.hh:209
Typed version of container::untyped::List.
Definition: container.hh:463
bool hasNext()
Definition: container.cc:789
void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition: container.hh:414
Stack(bool ownerOfObjects)
Definition: container.cc:715
void put(object::Object *key, object::Object *value)
Definition: container.cc:696
object::Object * value
Definition: container.hh:291
object::Object * object
Definition: container.hh:232
List::Node * current
Definition: container.hh:181
int size() const
Definition: container.hh:215