ooRexx  4.2.0-source
About: ooRexx (Open Object Rexx) is a free implementation of Object Rexx. Object Rexx is an enhancement of the classic Rexx interpreter; a full-featured programming language with a human-oriented syntax.
  Fossies Dox: ooRexx-4.2.0-source.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

ListClass.hpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2009 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.oorexx.org/license.html */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 /******************************************************************************/
39 /* REXX Kernel ListClass.hpp */
40 /* */
41 /* Primitive List Class Definitions */
42 /* */
43 /******************************************************************************/
44 #ifndef Included_RexxList
45 #define Included_RexxList
46 
47 #include "RexxListTable.hpp"
48 
49 #define INITIAL_LIST_SIZE 5 /* initial list allocation */
50 #define EXTEND_LIST_SIZE 5 /* amount to extend by each time */
51  /* size of buffer for a given number */
52  /* of list entries */
53 #define TABLE_SIZE(n) ((n)*sizeof(LISTENTRY))
54  /* number of list entries in a given */
55  /* buffer size */
56 #define ENTRY_COUNT(n) ((n)/sizeof(LISTENTRY))
57  /* address of a given buffer entry */
58 #define ENTRY_POINTER(n) (this->table->getData() + n)
59 #define ENTRY_INDEX(p) (p - this->table->getData())
60 #define LIST_END ((size_t)-1) /* end of list marker */
61 #define NOT_ACTIVE ((size_t)-2) /* free element marker */
62 
63  class RexxList : public RexxObject {
64  friend class RexxListTable;
65  public:
66  void * operator new(size_t);
67  inline void * operator new(size_t size, void *objectPtr) { return objectPtr; };
68  inline RexxList(RESTORETYPE restoreType) { ; };
69  inline RexxList() { ; }
70 
71  void init();
72  void live(size_t);
73  void liveGeneral(int reason);
74  void flatten(RexxEnvelope *);
75  RexxObject *copy();
80 
84  size_t firstIndex() { return first; }
85  size_t lastIndex() { return last; }
86  size_t nextIndex(size_t i);
87  size_t previousIndex(size_t i);
88  RexxObject *getValue(size_t i);
89 
97  inline size_t items() { return count; };
103  RexxObject *lastItem();
105  void partitionBuffer(size_t, size_t);
107  size_t getFree();
110  RexxObject *removeLast() { return (this->last != LIST_END) ? this->primitiveRemove(ENTRY_POINTER(this->last)) : TheNilObject; }
112  RexxObject *removeLastItem() { return (this->last != LIST_END) ? this->primitiveRemove(ENTRY_POINTER(this->last)) : OREF_NULL; }
113  RexxObject *removeIndex(size_t i) { return this->primitiveRemove(ENTRY_POINTER(i)); }
115  LISTENTRY *getEntry(size_t);
117  RexxObject *empty();
118  RexxObject *isEmpty();
123 
124  void addLast(RexxObject *value);
125  void addFirst(RexxObject *value);
126  inline size_t getSize() {return this->count;}
129 
130  RexxList *newRexx(RexxObject **, size_t);
131  RexxList *classOf(RexxObject **, size_t);
132 
133  static void createInstance();
135 
136  protected:
137 
138  RexxListTable *table; /* list table item */
139  size_t first; /* first real element index */
140  size_t last; /* last real element index */
141  size_t count; /* count of items in the list */
142  size_t size; /* element slots in the buffer */
143  size_t free; /* start of free element chain */
144  };
145 
146 
147 inline RexxList *new_list() { return new RexxList; }
148 
149 #endif
RexxList::liveGeneral
void liveGeneral(int reason)
Definition: ListClass.cpp:161
RexxList::count
size_t count
Definition: ListClass.hpp:141
RexxList::last
size_t last
Definition: ListClass.hpp:140
RexxArray
Definition: ArrayClass.hpp:100
RexxList::live
void live(size_t)
Definition: ListClass.cpp:152
RexxList::classOf
RexxList * classOf(RexxObject **, size_t)
Definition: ListClass.cpp:1238
RexxList::RexxList
RexxList()
Definition: ListClass.hpp:69
RexxList::allItems
RexxArray * allItems()
Definition: ListClass.cpp:887
RexxList::removeFirst
RexxObject * removeFirst()
Definition: ListClass.hpp:109
RexxList::init
void init()
Definition: ListClass.cpp:66
RexxList::hasIndex
RexxObject * hasIndex(RexxObject *)
Definition: ListClass.cpp:844
RexxList::value
RexxObject * value(RexxObject *)
Definition: ListClass.cpp:245
RexxListTable
Definition: RexxListTable.hpp:55
RexxList::add
RexxObject * add(RexxObject *, RexxObject *)
Definition: ListClass.cpp:380
RexxList::size
size_t size
Definition: ListClass.hpp:142
RexxList::firstRexx
RexxObject * firstRexx()
Definition: ListClass.cpp:711
RexxList::firstItem
RexxObject * firstItem()
Definition: ListClass.cpp:681
RexxList::removeIndex
RexxObject * removeIndex(size_t i)
Definition: ListClass.hpp:113
RexxList::indexOfValue
RexxObject * indexOfValue(RexxObject *)
Definition: ListClass.cpp:1081
RexxList::newRexx
RexxList * newRexx(RexxObject **, size_t)
Definition: ListClass.cpp:1212
RexxList::allIndexes
RexxArray * allIndexes()
Definition: ListClass.cpp:937
RexxList::previous
RexxObject * previous(RexxObject *)
Definition: ListClass.cpp:768
RexxList::removeLastItem
RexxObject * removeLastItem()
Definition: ListClass.hpp:112
RexxSupplier
Definition: SupplierClass.hpp:47
RexxList::removeLast
RexxObject * removeLast()
Definition: ListClass.hpp:110
RexxList::previousIndex
size_t previousIndex(size_t i)
Definition: ListClass.cpp:829
RexxEnvelope
Definition: RexxEnvelope.hpp:53
RexxList::addFirst
void addFirst(RexxObject *value)
Definition: ListClass.cpp:485
RexxList::first
size_t first
Definition: ListClass.hpp:139
RexxList::createInstance
static void createInstance()
Definition: ListClass.cpp:60
RexxList::copy
RexxObject * copy()
Definition: ListClass.cpp:78
RexxList::classInstance
static RexxClass * classInstance
Definition: ListClass.hpp:134
RexxList::nextIndex
size_t nextIndex(size_t i)
Definition: ListClass.cpp:803
RexxList::lastIndex
size_t lastIndex()
Definition: ListClass.hpp:85
RexxList::lastItem
RexxObject * lastItem()
Definition: ListClass.cpp:696
RexxList::itemsRexx
RexxObject * itemsRexx()
Definition: ListClass.cpp:1145
RexxListTable.hpp
RexxList::empty
RexxObject * empty()
Definition: ListClass.cpp:907
RexxList::hasItem
RexxObject * hasItem(RexxObject *)
Definition: ListClass.cpp:993
OREF_NULL
#define OREF_NULL
Definition: RexxCore.h:60
listentry
Definition: RexxListTable.hpp:49
RexxList::index
RexxObject * index(RexxObject *)
Definition: ListClass.cpp:963
RexxList::append
RexxObject * append(RexxObject *)
Definition: ListClass.cpp:537
RexxClass
Definition: ClassClass.hpp:49
RexxList::free
size_t free
Definition: ListClass.hpp:143
RexxList::flatten
void flatten(RexxEnvelope *)
Definition: ListClass.cpp:170
RexxList::removeObject
RexxObject * removeObject(RexxObject *)
Definition: ListClass.cpp:1057
RexxList::getValue
RexxObject * getValue(size_t i)
Definition: ListClass.cpp:275
RexxList::next
RexxObject * next(RexxObject *)
Definition: ListClass.cpp:743
RexxList::getFree
size_t getFree()
Definition: ListClass.cpp:114
RexxList::partitionBuffer
void partitionBuffer(size_t, size_t)
Definition: ListClass.cpp:91
RexxList::removeItem
RexxObject * removeItem(RexxObject *)
Definition: ListClass.cpp:1022
RexxList::remove
RexxObject * remove(RexxObject *)
Definition: ListClass.cpp:629
RexxList::primitiveRemove
RexxObject * primitiveRemove(LISTENTRY *)
Definition: ListClass.cpp:639
RexxList::put
RexxObject * put(RexxObject *, RexxObject *)
Definition: ListClass.cpp:288
RexxList::insertRexx
RexxObject * insertRexx(RexxObject *, RexxObject *)
Definition: ListClass.cpp:517
RexxList::RexxList
RexxList(RESTORETYPE restoreType)
Definition: ListClass.hpp:68
new_list
RexxList * new_list()
Definition: ListClass.hpp:147
RexxList::weakReferenceArray
RexxArray * weakReferenceArray()
Definition: ListClass.cpp:1155
RexxList::makeArrayIndices
RexxArray * makeArrayIndices()
Definition: ListClass.cpp:1111
TheNilObject
#define TheNilObject
Definition: RexxCore.h:180
RexxList::requestArray
RexxArray * requestArray()
Definition: ListClass.cpp:856
RexxList::getSize
size_t getSize()
Definition: ListClass.hpp:126
RexxList::lastRexx
RexxObject * lastRexx()
Definition: ListClass.cpp:727
LIST_END
#define LIST_END
Definition: ListClass.hpp:60
RexxList::sectionSubclass
RexxObject * sectionSubclass(LISTENTRY *, size_t)
Definition: ListClass.cpp:353
RexxList::getEntry
LISTENTRY * getEntry(RexxObject *, RexxObject *)
Definition: ListClass.cpp:183
RESTORETYPE
RESTORETYPE
Definition: ObjectClass.hpp:80
RexxList
Definition: ListClass.hpp:63
RexxList::section
RexxObject * section(RexxObject *, RexxObject *)
Definition: ListClass.cpp:308
RexxList::table
RexxListTable * table
Definition: ListClass.hpp:138
RexxList::firstIndex
size_t firstIndex()
Definition: ListClass.hpp:84
RexxList::items
size_t items()
Definition: ListClass.hpp:97
RexxList::removeFirstItem
RexxObject * removeFirstItem()
Definition: ListClass.hpp:111
RexxList::supplier
RexxSupplier * supplier()
Definition: ListClass.cpp:1130
RexxList::makeArray
RexxArray * makeArray()
Definition: ListClass.cpp:872
RexxList::addLast
void addLast(RexxObject *value)
Definition: ListClass.cpp:454
ENTRY_POINTER
#define ENTRY_POINTER(n)
Definition: ListClass.hpp:58
RexxList::insert
RexxObject * insert(RexxObject *, RexxObject *)
Definition: ListClass.cpp:545
RexxList::isEmpty
RexxObject * isEmpty()
Definition: ListClass.cpp:925
RexxObject
Definition: ObjectClass.hpp:311