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

Array.h

Go to the documentation of this file.
00001 /*
00002  * Array.h
00003  *
00004  * Smalltalk like class library for C++
00005  * Fixed 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 __ARRAY_H
00025 #define __ARRAY_H
00026 
00027 #include <stlib/SequenceableCollection.h>
00028 
00029 namespace Core {
00030 
00031 class CollectionIterator;
00032 class String;
00033 
00034 class Array : public SequenceableCollection
00035 {
00036   protected:
00037     Object **content;
00038     int tally;
00039 
00040   public:
00041     Array(int size = 0);
00042     virtual ~Array(void);
00043 
00044     /* Copying protocol */
00045     Array(const Array &origin);
00046 
00047     /* Class-accessing protocol */
00048     virtual String *className(void) const;
00049 
00050     /* Class-instance creation protocol */
00051     static Array *with(Object *object);
00052     static Array *with(Object *obj1, Object *obj2);
00053     static Array *with(Object *obj1, Object *obj2, Object *obj3);
00054     static Array *with(Object *obj1, Object *obj2, Object *obj3, Object *obj4);
00055 
00056     static Array *withAll(Collection *coll);
00057 
00058     /* Accessing protocol */
00059     virtual Object *any(void);
00060     virtual Object *at(int index) const;
00061     virtual void put(int index, Object *obj);
00062     virtual long size(void) const;
00063 
00064     /* Adding protocol */
00065     virtual void add(Object *);
00066     virtual void changeSize(long newSize);
00067 
00068     /* Converting protocol */
00069     virtual Array *asArray(void);
00070 
00071     /* Copying protocol */
00072     virtual Object *copy(void);
00073     virtual Object *copy(long from, long to)
00074     { return SequenceableCollection:: copy(from, to); }
00075     virtual Object *copyEmpty(long size);
00076 
00077   protected:
00078     /* Enumeration protocol */
00079     virtual Object *privNextForIterator(CollectionIterator *i) const;
00080 };
00081 
00082 };
00083 
00084 #endif /* __ARRAY_H */

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