#include <Array.h>
Inheritance diagram for Core::Array:
Public Member Functions | |
Array (int size=0) | |
virtual | ~Array (void) |
Array (const Array &origin) | |
virtual String * | className (void) const |
Answer receiver class name. | |
virtual Object * | any (void) |
Answer any item from the collection. | |
virtual Object * | at (int index) const |
virtual void | put (int index, Object *obj) |
virtual long | size (void) const |
Answer how many elements the collection includes. | |
virtual void | add (Object *) |
virtual void | changeSize (long newSize) |
virtual Array * | asArray (void) |
virtual Object * | copy (void) |
virtual Object * | copy (long from, long to) |
Returns a new collection with the same items as the specified portion of this collection. | |
virtual Object * | copyEmpty (long size) |
Static Public Member Functions | |
static Array * | with (Object *object) |
static Array * | with (Object *obj1, Object *obj2) |
static Array * | with (Object *obj1, Object *obj2, Object *obj3) |
static Array * | with (Object *obj1, Object *obj2, Object *obj3, Object *obj4) |
static Array * | withAll (Collection *coll) |
Protected Member Functions | |
virtual Object * | privNextForIterator (CollectionIterator *i) const |
Protected Attributes | |
Object ** | content |
int | tally |
|
Definition at line 31 of file Array.cc. References content, nil, and tally. Referenced by copy(), copyEmpty(), with(), and withAll(). 00032 { 00033 content = NULL; 00034 tally = size; 00035 if (tally > 0) { 00036 content = (Object **) GC_malloc(sizeof(Object *) * tally); 00037 for (int i = 0; i < tally; i++) { 00038 content[i] = nil; 00039 } 00040 } 00041 }
|
|
Definition at line 43 of file Array.cc. References content.
|
|
Definition at line 51 of file Array.cc. References content, and tally. 00052 : SequenceableCollection(origin) 00053 { 00054 content = NULL; 00055 tally = origin.tally; 00056 if (tally > 0) { 00057 content = (Object **) GC_malloc(sizeof(Object *) * tally); 00058 for (int i = 0; i < tally; i++) { 00059 content[i] = origin.content[i]; 00060 } 00061 } 00062 }
|
|
Reimplemented from Core::Collection. Definition at line 152 of file Array.cc. References Core::Object::shouldNotImplement(). 00153 { 00154 shouldNotImplement(new String(__PRETTY_FUNCTION__)); 00155 }
|
|
Answer any item from the collection.
Reimplemented from Core::SequenceableCollection. Definition at line 116 of file Array.cc. References at(), nil, and tally. Referenced by Core::Set::any(). 00117 { 00118 long idx = 0; 00119 do { 00120 if (at(idx) != nil) return at(idx); 00121 idx++; 00122 } while (idx < tally); 00123 return nil; 00124 }
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 179 of file Array.cc. 00180 { 00181 return this; 00182 }
|
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 157 of file Array.cc. References content, nil, and tally. Referenced by Core::CharacterArray::changeSize(). 00158 { 00159 Object **oldContent = content; 00160 long oldSize = tally; 00161 long i; 00162 00163 content = (Object **) GC_malloc(sizeof(Object *) * newSize); 00164 tally = newSize; 00165 00166 /* Copy old content or the part that fits */ 00167 for (i = 0; i < oldSize && i < tally; i++) { 00168 content[i] = oldContent[i]; 00169 } 00170 /* Fill the rest with nils */ 00171 for (; i < tally; i++) { 00172 content[i] = nil; 00173 } 00174 00175 GC_free(oldContent); 00176 }
|
|
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::Collection. Definition at line 65 of file Array.cc. 00066 { 00067 return new String("Array"); 00068 }
|
|
Returns a new collection with the same items as the specified portion of this collection.
Reimplemented from Core::SequenceableCollection. Definition at line 73 of file Array.h. References Core::SequenceableCollection::copy(). 00074 { return SequenceableCollection:: copy(from, to); }
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 185 of file Array.cc. References Array(). Referenced by Core::OrderedCollection::OrderedCollection(), and Core::Set::Set(). 00186 { 00187 return new Array(*this); 00188 }
|
|
Reimplemented from Core::Collection. Definition at line 190 of file Array.cc. References Array().
|
|
Reimplemented from Core::SequenceableCollection. Definition at line 197 of file Array.cc. References at(), and Core::CollectionIterator::position().
|
|
|
Answer how many elements the collection includes.
Reimplemented from Core::SequenceableCollection. Definition at line 146 of file Array.cc. References tally. Referenced by Core::Set::capacity(), Core::OrderedCollection::capacity(), Core::ByteCharacterEncoder::parseLine(), Core::CharacterArray::size(), and Net::IPSocketAddress::stringToBytes(). 00147 { 00148 return tally; 00149 }
|
|
Definition at line 95 of file Array.cc. References Array(), and put(). 00096 { 00097 Array *newArray = new Array(4); 00098 newArray->put(0, obj1); 00099 newArray->put(1, obj2); 00100 newArray->put(2, obj3); 00101 newArray->put(3, obj4); 00102 return newArray; 00103 }
|
|
Definition at line 86 of file Array.cc. References Array(), and put(). 00087 { 00088 Array *newArray = new Array(3); 00089 newArray->put(0, obj1); 00090 newArray->put(1, obj2); 00091 newArray->put(2, obj3); 00092 return newArray; 00093 }
|
|
Definition at line 78 of file Array.cc. References Array(), and put(). 00079 { 00080 Array *newArray = new Array(2); 00081 newArray->put(0, obj1); 00082 newArray->put(1, obj2); 00083 return newArray; 00084 }
|
|
Definition at line 71 of file Array.cc. References Array(), and put(). 00072 { 00073 Array *newArray = new Array(1); 00074 newArray->put(0, object); 00075 return newArray; 00076 }
|
|
Definition at line 105 of file Array.cc. References Array(), and put(). 00106 { 00107 Array *newArray = new Array(coll->size()); 00108 int index = 0; 00109 for (Iterator *i = coll->iterator(); !i->finished(); i->next()) { 00110 newArray->put(index++, i->value()); 00111 } 00112 return newArray; 00113 }
|
|
Definition at line 37 of file Array.h. Referenced by Array(), at(), changeSize(), put(), and ~Array(). |
|
Definition at line 38 of file Array.h. Referenced by any(), Array(), at(), changeSize(), put(), and size(). |