|
|
// List.cc - Coldstore Lists // Copyright (C) 1998,1999 Colin McCormack, // see LICENSE (MD5 f5220f8f599e5e926f37cf32efe3ab68) for terms // $Id: List.hh,v 1.2 1999/03/11 06:51:06 colin Exp $ #ifndef LIST_HH #define LIST_HH #include "Vector.hh" /** dynamic ordinally indexed array of @see Slot */ class List : public Data, public Vector<Slot> { public: // Constructors /** construct a List of given size (default 0) */ List(int size = 0); /** construct a List from a sequence Slot */ List(const Slot &sequence); /** construct a List from an array of @see Slot */ List(const Slot *contentT, int additional); /** construct a List by repeating a @see Slot */ List(const Slot &contentT, int repetition); /** copy construct a List */ List(const List *contentT); /** copy construct a subList */ List(const List *contentT, int start, int l); /** copy construct a List */ List(const List &contentT); /** copy construct a subList */ List(const List &contentT, int start, int l); /** construct a List from a Tuple */ List(const Tuple *contentT); /** construct a List from a subTuple */ List(const Tuple *contentT, int start, int l); virtual ~List(); virtual void check(int=0) const; //Slot &List::operator [] (const Data &i) const; /** factor List into: [list1-only, intersection, list2-only] */ Slot factor(const List *l) const; Slot explode(); public: /////////////////////////////// // Coldmud Interface // structural virtual Data *clone(void *store = (void*)0) const; virtual Data *mutate(void *store = (void*)0) const; // object virtual bool truth() const; virtual Slot toconstruct() const; virtual ostream &dump(ostream&) const; static Slot construct(const Slot &arg); virtual int order(const Slot &arg) const; virtual bool equal(const Slot &) const; // arithmetic virtual Slot positive() { // monadic `+', absolute value return qsort(); } virtual Slot negative() { // monadic `-', negative absolute value return reverse(); } virtual Slot add(const Slot &arg); #if 0 virtual Slot subtract(const Slot &arg); virtual Slot multiply(const Slot &arg); virtual Slot divide(const Slot &arg); virtual Slot modulo(const Slot &arg); // bitwise virtual Slot invert(); virtual Slot and(const Slot &arg); virtual Slot xor(const Slot &arg); virtual Slot or(const Slot &arg); virtual Slot lshift(const Slot &arg); virtual Slot rshift(const Slot &arg); #endif // sequence virtual bool isSequence(); virtual int length() const; virtual Slot concat(const Slot &arg); virtual Slot slice(const Slot &from, const Slot &len) const; virtual Slot slice(const Slot &from) const; virtual Slot replace(const Slot &from, const Slot &to, const Slot &value); virtual Slot replace(const Slot &from, const Slot &val); virtual Slot replace(const Slot &val); virtual Slot insert(const Slot &from, const Slot &val); virtual Slot insert(const Slot &val); virtual Slot del(const Slot &from, const Slot &len); virtual Slot del(const Slot &from); virtual Slot search(const Slot &search) const; virtual Slot toSequence() const; // iterator virtual Slot iterator() const ; // List is its own iterator bool More() const; Slot Current(); Slot Next(); // additional ops virtual Slot qsort(); virtual Slot reverse(); // hoist some Vector methods to enable children to use them Vector<Slot>::vconcat; Vector<Slot>::Replace; // stack ops void push(const Slot &val); Slot pop(); }; #endif
Generated by: colin@sharedtech.dhis.org on Sat Sep 4 22:38:36 199. |