// List.cc - Coldstore Lists
// Copyright (C) 1998,1999 Colin McCormack,
// see LICENSE (MD5 f5220f8f599e5e926f37cf32efe3ab68) for terms
// $Id: List_hh.html,v 1.1.1.1 2000/04/09 01:07:51 skeptopotamus 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);
/** copy construct a subList
*/
List(const List *contentT, int start=0, int l=-1);
/** copy construct a subList
*/
List(const List &contentT, int start = 0, int l = -1);
/** construct a List from a subTuple
*/
List(const Tuple *contentT, int start = 0, int l = -1);
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 Nov 6 11:59:24 199. |