![]() |
The Simons
|
00001 00002 // 00003 // SCL : Simons Component Library 00004 // 00006 // 00007 // Filename: Vector.h 00008 // Contents: Vector class 00009 // Author: Anthony J H Simons 00010 // Revised: 8 November 2005 00011 00012 // This software is distributed free in the hope that others will 00013 // find it useful. However, it comes WITHOUT ANY WARRANTY. No 00014 // liability can be accepted for software failure, merchantability 00015 // or fitness for a particular purpose. You can redistribute this 00016 // software in its original form, or in a modified form, provided 00017 // that this disclaimer is retained in the file banner. 00018 00019 #ifndef SCL_VECTOR 00020 #define SCL_VECTOR 00021 00022 #include "Sequence.h" // Include the superclass type 00023 #include "VectorID.h" // Include the pointer type 00024 00033 00034 class Vector : public Sequence { 00035 private: 00036 Natural alloc; 00037 Natural items; 00038 ObjectID* block; 00039 enum Constants { INITIAL = 16 }; 00040 Vector(const Vector&); 00041 public: 00042 Vector(); 00043 Vector(Natural); 00044 Vector(CollectionID); 00045 virtual ~Vector(); 00046 virtual ObjectID clone() const; 00047 Natural size() const; 00048 virtual ObjectID last() const; 00049 virtual Void addLast(ObjectID); 00050 virtual Void removeLast(); 00051 virtual ObjectID getAt(Integer) const; 00052 virtual Void putAt(Integer, ObjectID); 00053 virtual Void addAt(Integer, ObjectID); 00054 virtual Void removeAt(Integer); 00055 }; 00056 00058 00061 inline VectorID::VectorID() {} 00062 00064 inline VectorID::~VectorID() {} 00065 00069 inline VectorID::VectorID(const Null* null) : 00070 SequenceID(null) {} 00071 00075 inline VectorID::VectorID(const Vector* vector) : 00076 SequenceID(vector) {} 00077 00081 inline VectorID::VectorID(const VectorID& pointer) : 00082 SequenceID(pointer) {} 00083 00087 inline VectorID& VectorID::operator=(const Vector* vector) { 00088 assign(vector); 00089 return *this; 00090 } 00091 00096 inline VectorID& VectorID::operator=(const VectorID& pointer) { 00097 assign(pointer); 00098 return *this; 00099 } 00100 00101 00102 #endif 00103 00104