#include <Collection.h>
Inheritance diagram for Core::Collection:
Public Member Functions | |
virtual String * | className (void) const |
Answer receiver class name. | |
virtual long | capacity (void) const |
Answer how many elements can be stored in the collection. | |
virtual long | size (void) const abstract |
Answer how many elements the collection includes. | |
virtual Object * | any (void) abstract |
Answer any item from the collection. | |
virtual void | add (Object *) abstract |
virtual void | addAll (Collection *) |
virtual Array * | asArray (void) |
virtual OrderedCollection * | asOrderedCollection (void) |
virtual Set * | asSet (void) |
virtual Object * | copy (void) abstract |
virtual Object * | copyEmpty (long size) abstract |
virtual Iterator * | iterator (void) const |
virtual void | printOn (Stream *stream) const |
Print object identification into the stream. | |
virtual String * | printSeparatedBy (String *separator) const |
virtual String * | printSeparatedBy (const char *separator) const |
virtual void | printSeparatedOn (Stream *stream, String *separator) const |
virtual void | printSeparatedOn (Stream *stream, const char *separator) const |
virtual Object * | remove (Object *) abstract |
virtual void | removeAll (Collection *items) |
virtual bool | includes (Object *) |
virtual bool | isByteArray (void) |
virtual bool | isEmpty (void) |
virtual bool | isSequenceable (void) const |
virtual void | visitBy (Visitor *visitor) |
Protected Member Functions | |
virtual Object * | privNextForIterator (CollectionIterator *iter) const abstract |
virtual void | emptyCheck (void) |
virtual long | growSize (void) |
Friends | |
void | CollectionIterator::next (void) |
|
Reimplemented in Core::Array, Core::ByteArray, Core::Dictionary, Core::OrderedCollection, Core::Set, and Core::String. Referenced by addAll(). |
|
Definition at line 49 of file Collection.cc. References add(), Core::Iterator::finished(), iterator(), Core::Iterator::next(), and Core::Iterator::value(). 00050 { 00051 Iterator *i; 00052 for (i = otherColl->iterator(); !i->finished(); i->next()) { 00053 add(i->value()); 00054 } 00055 }
|
|
Answer any item from the collection.
Reimplemented in Core::Array, Core::SequenceableCollection, and Core::Set. |
|
Reimplemented in Core::Array, and Core::SequenceableCollection. Definition at line 58 of file Collection.cc. References Core::Iterator::finished(), iterator(), Core::Iterator::next(), Core::Array::put(), size(), and Core::Iterator::value(). 00059 { 00060 Array *array; 00061 Iterator *i; 00062 int idx; 00063 00064 array = new Array(size()); 00065 for (idx = 0, i = iterator(); !i->finished(); i->next(), idx++) { 00066 array->put(idx, i->value()); 00067 } 00068 delete i; 00069 return array; 00070 }
|
|
Reimplemented in Core::OrderedCollection. Definition at line 72 of file Collection.cc. References Core::OrderedCollection::addLast(), iterator(), and size(). 00073 { 00074 OrderedCollection *coll; 00075 00076 coll = new OrderedCollection(size()); 00077 for (Iterator *i = iterator(); !i->finished(); i->next()) { 00078 coll->addLast(i->value()); 00079 } 00080 return coll; 00081 }
|
|
Reimplemented in Core::Set. Definition at line 83 of file Collection.cc. References Core::Set::add(), Core::Iterator::finished(), iterator(), Core::Iterator::next(), size(), and Core::Iterator::value(). 00084 { 00085 Set *set; 00086 Iterator *i; 00087 00088 set = new Set(size()); 00089 for (i = iterator(); !i->finished(); i->next()) { 00090 set->add(i->value()); 00091 } 00092 delete i; 00093 return set; 00094 }
|
|
Answer how many elements can be stored in the collection.
Reimplemented in Core::OrderedCollection, and Core::Set. Definition at line 43 of file Collection.cc. References size(). Referenced by Core::CollectionIterator::finished(), and growSize(). 00044 { 00045 return size(); 00046 }
|
|
Answer receiver class name. Because there isn't any standard way to obtain class name this method comes to place. Every class should rewrite this method but many didn't (yet). Reimplemented from Core::Object. Reimplemented in Core::Array, Core::ByteArray, Core::Dictionary, Core::OrderedCollection, Core::Set, and Core::String. Definition at line 37 of file Collection.cc. Referenced by printOn(). 00038 { 00039 return new String("Collection"); 00040 }
|
|
Reimplemented in Core::Array, Core::ByteArray, Core::Dictionary, Core::OrderedCollection, Core::SequenceableCollection, Core::Set, and Core::String. |
|
Reimplemented in Core::Array, Core::Dictionary, Core::OrderedCollection, Core::Set, and Core::String. Referenced by Core::PositionableStream::contentSpeciesFor(), Core::SequenceableCollection::copy(), and Core::SequenceableCollection::copyReplace(). |
|
Definition at line 194 of file Collection.cc. References Core::Object::error(), and isEmpty(). Referenced by Core::SequenceableCollection::first(), Core::OrderedCollection::first(), Core::SequenceableCollection::last(), Core::OrderedCollection::last(), Core::OrderedCollection::removeFirst(), and Core::OrderedCollection::removeLast(). 00195 { 00196 if (isEmpty()) 00197 error(new String("This collection is empty."), 00198 new String(__PRETTY_FUNCTION__)); 00199 }
|
|
Definition at line 201 of file Collection.cc. References capacity(). Referenced by Core::Set::grow(), Core::SequenceableCollection::grow(), Core::SequenceableCollection::growToAtLeast(), and Core::OrderedCollection::increaseCapacity(). 00202 { 00203 long cap = capacity(); 00204 return cap > 2 ? cap : 2; 00205 }
|
|
Reimplemented in Core::Dictionary, Core::Set, and Core::String. Definition at line 157 of file Collection.cc. References Core::Iterator::finished(), iterator(), Core::Iterator::next(), and Core::Iterator::value(). Referenced by Core::String::includes(), and Core::Dictionary::includes(). 00158 { 00159 Iterator *i; 00160 00161 for (i = iterator(); !i->finished(); i->next()) { 00162 if (i->value()->isEqual(obj)) { 00163 delete i; 00164 return true; 00165 } 00166 } 00167 delete i; 00168 return false; 00169 }
|
|
Reimplemented in Core::ByteArray. Definition at line 171 of file Collection.cc. Referenced by Core::PositionableStream::isBinary(). 00172 { 00173 return false; 00174 }
|
|
|
Reimplemented in Core::SequenceableCollection. Definition at line 181 of file Collection.cc. Referenced by Core::Stream::nextPutAll(). 00182 { 00183 return false; 00184 }
|
|
|
Print object identification into the stream. Object identification is formed from its className() by default. But complicated classes (eg. collections) may print some other information.
Reimplemented from Core::Object. Reimplemented in Core::String. Definition at line 103 of file Collection.cc. References className(), Core::Iterator::finished(), iterator(), Core::Iterator::next(), Core::Stream::nextPut(), Core::Stream::nextPutAll(), nil, Core::Stream::space(), and Core::Iterator::value(). 00104 { 00105 Iterator *i; 00106 stream->nextPutAll(className()); 00107 stream->nextPutAll(" ("); 00108 i = iterator(); 00109 while (!i->finished()) { 00110 if (i->value() == nil) stream->nextPutAll("nil"); 00111 else i->value()->printOn(stream); 00112 i->next(); 00113 if (!i->finished()) { 00114 stream->space(); 00115 } 00116 } 00117 stream->nextPut(')'); 00118 delete i; 00119 }
|
|
Definition at line 128 of file Collection.cc. References printSeparatedBy(). 00129 { 00130 return printSeparatedBy(new String(separator)); 00131 }
|
|
Definition at line 121 of file Collection.cc. References Core::Stream::contents(), and printSeparatedOn(). Referenced by Net::IPSocketAddress::bytesToName(), and printSeparatedBy(). 00122 { 00123 Stream *stream = (new String(20))->writeStream(); 00124 printSeparatedOn(stream, separator); 00125 return dynamic_cast<String *>(stream->contents()); 00126 }
|
|
Definition at line 143 of file Collection.cc. References printSeparatedOn(). 00144 { 00145 printSeparatedOn(stream, new String(separator)); 00146 }
|
|
Definition at line 133 of file Collection.cc. References iterator(), and Core::Stream::nextPutAll(). Referenced by printSeparatedBy(), and printSeparatedOn(). 00134 { 00135 bool first = true; 00136 for (Iterator *i = iterator(); !i->finished(); i->next()) { 00137 if (!first) stream->nextPutAll(separator); 00138 i->value()->printOn(stream); 00139 first = false; 00140 } 00141 }
|
|
Reimplemented in Core::Array, Core::OrderedCollection, Core::SequenceableCollection, and Core::Set. Referenced by Core::CollectionIterator::next(). |
|
Reimplemented in Core::Dictionary, Core::OrderedCollection, Core::SequenceableCollection, and Core::Set. Referenced by removeAll(). |
|
Definition at line 149 of file Collection.cc. References iterator(), and remove(). 00150 { 00151 for (Iterator *i = items->iterator(); !i->finished(); i->next()) { 00152 remove(i->value()); 00153 } 00154 }
|
|
Answer how many elements the collection includes.
Reimplemented in Core::Array, Core::ByteArray, Core::OrderedCollection, Core::SequenceableCollection, Core::Set, and Core::String. Referenced by asArray(), asOrderedCollection(), asSet(), capacity(), and isEmpty(). |
|
Reimplemented from Core::Object. Reimplemented in Core::Dictionary, and Core::String. Definition at line 187 of file Collection.cc. References Core::Visitor::visitCollection(). 00188 { 00189 visitor->visitCollection(this); 00190 }
|
|
|