Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

OrderedCollection.h

Go to the documentation of this file.
00001 /*
00002  * OrderedCollection.h
00003  *
00004  * Smalltalk like class library for C++
00005  * Variable size collection, index-accessable. Header.
00006  *
00007  * Copyright (c) 2003 Milan Cermak
00008  */
00009 /*
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  */
00024 #ifndef __ORDEREDCOLLECTION_H
00025 #define __ORDEREDCOLLECTION_H
00026 
00027 #include <stlib/SequenceableCollection.h>
00028 #include <stlib/String.h>
00029 
00030 #include <stlib/SOOBoundsError.h>
00031 
00032 namespace Core {
00033 
00034 class Array;
00035 class CollectionIterator;
00036 
00037 class OrderedCollection : public SequenceableCollection
00038 {
00039   protected:
00040     Array *content;
00041     int firstIndex, lastIndex;
00042 
00043   public:
00044     OrderedCollection(int size = 5);
00045     virtual ~OrderedCollection(void);
00046 
00047     /* Copying protocol */
00048     OrderedCollection(const OrderedCollection &origin);
00049 
00050     /* Class-accessing protocol */
00051     virtual String *className(void) const;
00052 
00053     /* Class-instance creation protocol */
00054     static OrderedCollection *with(Object *object);
00055     static OrderedCollection *with(Object *obj1, Object *obj2);
00056     static OrderedCollection *with(Object *obj1, Object *obj2, Object *obj3);
00057     static OrderedCollection *with(Object *obj1, Object *obj2, Object *obj3, Object *obj4);
00058 
00059     static OrderedCollection *withAll(Collection *coll);
00060 
00061     /* Accessing protocol */
00062     virtual Object *at(int index) const;
00063     virtual void put(int index, Object *obj);
00064     virtual long capacity(void) const;
00065     virtual long size(void) const;
00066     virtual Object *first(void);
00067     virtual Object *last(void);
00068 
00069     /* Adding protocol */
00070     virtual void add(Object *);
00071     virtual void addFirst(Object *);
00072     virtual void addLast(Object *);
00073     virtual void changeSize(long newSize);
00074 
00075     /* Converting protocol */
00076     virtual OrderedCollection *asOrderedCollection(void);
00077 
00078     /* Copying protocol */
00079     virtual Object *copy(void);
00080     virtual Object *copy(int from, int to)
00081       { return SequenceableCollection::copy(from, to); }
00082     virtual Object *copyEmpty(long size);
00083 
00084     /* Removing protocol */
00085     virtual Object *remove(Object *);
00086     virtual Object *removeFirst(void);
00087     virtual Object *removeLast(void);
00088 
00089   protected:
00090     /* Enumeration protocol */
00091     virtual Object *privNextForIterator(CollectionIterator *iter) const;
00092 
00093     /* Private protocol */
00094     virtual void changeCapacity(int newCapacity);
00095     virtual void grow(void);
00096     virtual void increaseCapacity(void);
00097     virtual void makeRoomAtFirst(void);
00098     virtual void makeRoomAtLast(void);
00099     virtual void removeIndex(int index);
00100 };
00101 
00102 };
00103 
00104 #endif /* __ORDEREDCOLLECTION_H */

Generated on Mon Nov 27 09:47:55 2006 for Smalltalk like C++ Class Library by  doxygen 1.4.2