From 936f52d677ed75457456117c15ef18b27bc842d7 Mon Sep 17 00:00:00 2001 From: CSRG Date: Thu, 21 Jun 1990 13:00:10 -0800 Subject: [PATCH] BSD 4_3_Net_2 development Work on file usr/src/lib/libg++/g++-include/gen/XPlex.hP Work on file usr/src/lib/libg++/g++-include/gen/XPStack.hP Work on file usr/src/lib/libg++/g++-include/gen/XPSet.hP Work on file usr/src/lib/libg++/g++-include/gen/XPPQ.hP Work on file usr/src/lib/libg++/g++-include/gen/XPQueue.hP Work on file usr/src/lib/libg++/g++-include/gen/XPDeque.hP Work on file usr/src/lib/libg++/g++-include/gen/Vec.hP Work on file usr/src/lib/libg++/g++-include/gen/XPBag.hP Work on file usr/src/lib/libg++/g++-include/gen/VStack.hP Work on file usr/src/lib/libg++/g++-include/gen/VQueue.hP Work on file usr/src/lib/libg++/g++-include/gen/VOHSet.hP Work on file usr/src/lib/libg++/g++-include/gen/VHSet.hP Work on file usr/src/lib/libg++/g++-include/gen/VHBag.hP Work on file usr/src/lib/libg++/g++-include/gen/VHMap.hP Work on file usr/src/lib/libg++/g++-include/gen/Stack.hP Work on file usr/src/lib/libg++/g++-include/gen/SplaySet.hP Work on file usr/src/lib/libg++/g++-include/gen/SplayPQ.hP Work on file usr/src/lib/libg++/g++-include/gen/SplayMap.hP Work on file usr/src/lib/libg++/g++-include/gen/SplayBag.hP Work on file usr/src/lib/libg++/g++-include/gen/Set.hP Work on file usr/src/lib/libg++/g++-include/gen/SLStack.hP Work on file usr/src/lib/libg++/g++-include/gen/SLSet.hP Work on file usr/src/lib/libg++/g++-include/gen/SLList.hP Work on file usr/src/lib/libg++/g++-include/gen/SLQueue.hP Work on file usr/src/lib/libg++/g++-include/gen/SLBag.hP Work on file usr/src/lib/libg++/g++-include/gen/RPlex.hP Work on file usr/src/lib/libg++/g++-include/gen/RAVLMap.hP Work on file usr/src/lib/libg++/g++-include/gen/Queue.hP Work on file usr/src/lib/libg++/g++-include/gen/Plex.hP Work on file usr/src/lib/libg++/g++-include/gen/PHPQ.hP Work on file usr/src/lib/libg++/g++-include/gen/OXPSet.hP Work on file usr/src/lib/libg++/g++-include/gen/OXPBag.hP Work on file usr/src/lib/libg++/g++-include/gen/OSLSet.hP Work on file usr/src/lib/libg++/g++-include/gen/OSLBag.hP Work on file usr/src/lib/libg++/g++-include/gen/Map.hP Work on file usr/src/lib/libg++/g++-include/gen/List.hP Work on file usr/src/lib/libg++/g++-include/gen/FPlex.hP Work on file usr/src/lib/libg++/g++-include/gen/Deque.hP Work on file usr/src/lib/libg++/g++-include/gen/DLList.hP Work on file usr/src/lib/libg++/g++-include/gen/DLDeque.hP Work on file usr/src/lib/libg++/g++-include/gen/CHSet.hP Work on file usr/src/lib/libg++/g++-include/gen/CHBag.hP Work on file usr/src/lib/libg++/g++-include/gen/Bag.hP Synthesized-from: CSRG/cd2/net.2 --- usr/src/lib/libg++/g++-include/gen/Bag.hP | 87 +++ usr/src/lib/libg++/g++-include/gen/CHBag.hP | 110 ++++ usr/src/lib/libg++/g++-include/gen/CHSet.hP | 121 +++++ usr/src/lib/libg++/g++-include/gen/DLDeque.hP | 138 +++++ usr/src/lib/libg++/g++-include/gen/DLList.hP | 170 ++++++ usr/src/lib/libg++/g++-include/gen/Deque.hP | 67 +++ usr/src/lib/libg++/g++-include/gen/FPlex.hP | 263 +++++++++ usr/src/lib/libg++/g++-include/gen/List.hP | 279 ++++++++++ usr/src/lib/libg++/g++-include/gen/Map.hP | 96 ++++ usr/src/lib/libg++/g++-include/gen/OSLBag.hP | 100 ++++ usr/src/lib/libg++/g++-include/gen/OSLSet.hP | 109 ++++ usr/src/lib/libg++/g++-include/gen/OXPBag.hP | 76 +++ usr/src/lib/libg++/g++-include/gen/OXPSet.hP | 110 ++++ usr/src/lib/libg++/g++-include/gen/PHPQ.hP | 118 ++++ usr/src/lib/libg++/g++-include/gen/Plex.hP | 503 ++++++++++++++++++ usr/src/lib/libg++/g++-include/gen/Queue.hP | 62 +++ usr/src/lib/libg++/g++-include/gen/RAVLMap.hP | 162 ++++++ usr/src/lib/libg++/g++-include/gen/RPlex.hP | 268 ++++++++++ usr/src/lib/libg++/g++-include/gen/SLBag.hP | 104 ++++ usr/src/lib/libg++/g++-include/gen/SLList.hP | 152 ++++++ usr/src/lib/libg++/g++-include/gen/SLQueue.hP | 118 ++++ usr/src/lib/libg++/g++-include/gen/SLSet.hP | 97 ++++ usr/src/lib/libg++/g++-include/gen/SLStack.hP | 119 +++++ usr/src/lib/libg++/g++-include/gen/Set.hP | 88 +++ .../lib/libg++/g++-include/gen/SplayBag.hP | 160 ++++++ .../lib/libg++/g++-include/gen/SplayMap.hP | 166 ++++++ usr/src/lib/libg++/g++-include/gen/SplayPQ.hP | 157 ++++++ .../lib/libg++/g++-include/gen/SplaySet.hP | 167 ++++++ usr/src/lib/libg++/g++-include/gen/Stack.hP | 62 +++ usr/src/lib/libg++/g++-include/gen/VHBag.hP | 92 ++++ usr/src/lib/libg++/g++-include/gen/VHMap.hP | 94 ++++ usr/src/lib/libg++/g++-include/gen/VHSet.hP | 105 ++++ usr/src/lib/libg++/g++-include/gen/VOHSet.hP | 97 ++++ usr/src/lib/libg++/g++-include/gen/VQueue.hP | 139 +++++ usr/src/lib/libg++/g++-include/gen/VStack.hP | 128 +++++ usr/src/lib/libg++/g++-include/gen/Vec.hP | 142 +++++ usr/src/lib/libg++/g++-include/gen/XPBag.hP | 105 ++++ usr/src/lib/libg++/g++-include/gen/XPDeque.hP | 142 +++++ usr/src/lib/libg++/g++-include/gen/XPPQ.hP | 115 ++++ usr/src/lib/libg++/g++-include/gen/XPQueue.hP | 123 +++++ usr/src/lib/libg++/g++-include/gen/XPSet.hP | 99 ++++ usr/src/lib/libg++/g++-include/gen/XPStack.hP | 124 +++++ usr/src/lib/libg++/g++-include/gen/XPlex.hP | 248 +++++++++ 43 files changed, 5982 insertions(+) create mode 100644 usr/src/lib/libg++/g++-include/gen/Bag.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/CHBag.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/CHSet.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/DLDeque.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/DLList.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/Deque.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/FPlex.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/List.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/Map.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/OSLBag.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/OSLSet.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/OXPBag.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/OXPSet.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/PHPQ.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/Plex.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/Queue.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/RAVLMap.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/RPlex.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/SLBag.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/SLList.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/SLQueue.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/SLSet.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/SLStack.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/Set.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/SplayBag.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/SplayMap.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/SplayPQ.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/SplaySet.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/Stack.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/VHBag.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/VHMap.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/VHSet.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/VOHSet.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/VQueue.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/VStack.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/Vec.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/XPBag.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/XPDeque.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/XPPQ.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/XPQueue.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/XPSet.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/XPStack.hP create mode 100644 usr/src/lib/libg++/g++-include/gen/XPlex.hP diff --git a/usr/src/lib/libg++/g++-include/gen/Bag.hP b/usr/src/lib/libg++/g++-include/gen/Bag.hP new file mode 100644 index 0000000000..af87a8ba53 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/Bag.hP @@ -0,0 +1,87 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _Bag_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _Bag_h 1 + +#include +#include ".defs.h" + +class Bag +{ +protected: + int count; + +public: + virtual ~Bag(); + + int length(); // current number of items + int empty(); + + virtual Pix add( item) = 0; // add item; return Pix + + virtual void del( item) = 0; // delete 1 occurrence of item + virtual void remove( item); // delete all occurrences + virtual void clear(); // delete all items + + virtual int contains( item); // is item in Bag? + virtual int nof( item); // how many in Bag? + + virtual Pix first() = 0; // Pix of first item or 0 + virtual void next(Pix& i) = 0; // advance to next or 0 + + virtual & operator () (Pix i) = 0; // access item at i + + virtual Pix seek( item, Pix from=0); // Pix of next occurrence + virtual int owns(Pix i); // is i a valid Pix ? + + void error(const char* msg); + virtual int OK() = 0; // rep invariant +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline Bag::~Bag() {} + +inline int Bag::length() +{ + return count; +} + +inline int Bag::empty() +{ + return count == 0; +} + +inline int Bag::contains( item) +{ + return seek(item) != 0; +} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/CHBag.hP b/usr/src/lib/libg++/g++-include/gen/CHBag.hP new file mode 100644 index 0000000000..5254f8ff96 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/CHBag.hP @@ -0,0 +1,110 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _CHBag_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _CHBag_h 1 + +#include ".Bag.h" + + +#ifndef _CHNode_h +#define _CHNode_h 1 + +struct CHNode +{ + CHNode* tl; + hd; + CHNode(); + CHNode( h, CHNode* t = 0); + ~CHNode(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline CHNode::CHNode() {} + +inline CHNode::CHNode( h, CHNode* t) :hd(h), tl(t) {} + +inline CHNode::~CHNode() {} + +#endif + +typedef CHNode* CHNodePtr; + +#endif + + +class CHBag : public Bag +{ +protected: + CHNode** tab; + unsigned int size; + +public: + CHBag(unsigned int sz = DEFAULT_INITIAL_CAPACITY); + CHBag(CHBag& a); + ~CHBag(); + + Pix add( item); + void del( item); + void remove(item); + int nof( item); + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + Pix seek( item, Pix from = 0); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline CHBag::~CHBag() +{ + clear(); + delete tab; +} + +inline int CHBag::contains( key) +{ + return seek(key) != 0; +} + +inline & CHBag::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return ((CHNode*)i)->hd; +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/CHSet.hP b/usr/src/lib/libg++/g++-include/gen/CHSet.hP new file mode 100644 index 0000000000..51cad80a95 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/CHSet.hP @@ -0,0 +1,121 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _CHSet_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _CHSet_h 1 + +#include ".Set.h" + + +#ifndef _CHNode_h +#define _CHNode_h 1 + +struct CHNode +{ + CHNode* tl; + hd; + CHNode(); + CHNode( h, CHNode* t = 0); + ~CHNode(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline CHNode::CHNode() {} + +inline CHNode::CHNode( h, CHNode* t) : hd(h), tl(t) {} + +inline CHNode::~CHNode() {} + +#endif + +typedef CHNode* CHNodePtr; + +#endif + + +class CHSet : public Set +{ +protected: + CHNode** tab; + unsigned int size; + +public: + CHSet(unsigned int sz = DEFAULT_INITIAL_CAPACITY); + CHSet(CHSet& a); + ~CHSet(); + + Pix add( item); + void del( item); + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + Pix seek( item); + + void operator |= (CHSet& b); + void operator -= (CHSet& b); + void operator &= (CHSet& b); + + int operator == (CHSet& b); + int operator != (CHSet& b); + int operator <= (CHSet& b); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline CHSet::~CHSet() +{ + clear(); + delete tab; +} + +inline int CHSet::contains( key) +{ + return seek(key) != 0; +} + +inline & CHSet::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return ((CHNode*)i)->hd; +} + +inline int CHSet::operator != (CHSet& b) +{ + return ! ((*this) == b); +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/DLDeque.hP b/usr/src/lib/libg++/g++-include/gen/DLDeque.hP new file mode 100644 index 0000000000..5ef7c4cdfc --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/DLDeque.hP @@ -0,0 +1,138 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _DLDeque_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _DLDeque_h + +#include ".DLList.h" +#include ".Deque.h" + +class DLDeque : public Deque +{ + DLList p; + +public: + DLDeque(); + DLDeque(const DLDeque& d); + ~DLDeque(); + + void operator = (const DLDeque&); + + void push( item); // insert at front + void enq( item); // insert at rear + + & front(); + & rear(); + + deq(); + void del_front(); + void del_rear(); + + void clear(); + int empty(); + int full(); + int length(); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline DLDeque::DLDeque() : p() {} +inline DLDeque::DLDeque(const DLDeque& d) : p(d.p) {} + +inline DLDeque::~DLDeque() {} + +inline void DLDeque::push(item) +{ + p.prepend(item); +} + +inline void DLDeque::enq(item) +{ + p.append(item); +} + +inline DLDeque::deq() +{ + return p.remove_front(); +} + +inline & DLDeque::front() +{ + return p.front(); +} + +inline & DLDeque::rear() +{ + return p.rear(); +} + +inline void DLDeque::del_front() +{ + p.del_front(); +} + +inline void DLDeque::del_rear() +{ + p.del_rear(); +} + +inline void DLDeque::operator =(const DLDeque& s) +{ + p.operator = (s.p); +} + + +inline int DLDeque::empty() +{ + return p.empty(); +} + +inline int DLDeque::full() +{ + return 0; +} + +inline int DLDeque::length() +{ + return p.length(); +} + +inline int DLDeque::OK() +{ + return p.OK(); +} + +inline void DLDeque::clear() +{ + p.clear(); +} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/DLList.hP b/usr/src/lib/libg++/g++-include/gen/DLList.hP new file mode 100644 index 0000000000..511c7b5523 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/DLList.hP @@ -0,0 +1,170 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _DLList_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _DLList_h 1 + +#include +#include ".defs.h" + +#ifndef _DLListNode_h +#define _DLListNode_h 1 + +struct DLListNode +{ + DLListNode* bk; + DLListNode* fd; + hd; + DLListNode(); + DLListNode( h, + DLListNode* p = 0, + DLListNode* n = 0); + ~DLListNode(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline DLListNode::DLListNode() {} + +inline DLListNode::DLListNode( h, DLListNode* p, + DLListNode* n) + :hd(h), bk(p), fd(n) {} + +inline DLListNode::~DLListNode() {} + +#endif + +typedef DLListNode* DLListNodePtr; + +#endif + +class DLList +{ + friend class DLListTrav; + + DLListNode* h; + +public: + DLList(); + DLList(DLList& a); + ~DLList(); + + DLList& operator = (DLList& a); + + int empty(); + int length(); + + void clear(); + + Pix prepend( item); + Pix append( item); + void join(DLList&); + + & front(); + remove_front(); + void del_front(); + + & rear(); + remove_rear(); + void del_rear(); + + & operator () (Pix p); + Pix first(); + Pix last(); + void next(Pix& p); + void prev(Pix& p); + int owns(Pix p); + Pix ins_after(Pix p, item); + Pix ins_before(Pix p, item); + void del(Pix& p, int dir = 1); + + void error(const char* msg); + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline DLList::~DLList() +{ + clear(); +} + +inline DLList::DLList() +{ + h = 0; +} + +inline int DLList::empty() +{ + return h == 0; +} + + +inline void DLList::next(Pix& p) +{ + p = (p == 0 || p == h->bk)? 0 : Pix(((DLListNode*)p)->fd); +} + +inline void DLList::prev(Pix& p) +{ + p = (p == 0 || p == h)? 0 : Pix(((DLListNode*)p)->bk); +} + +inline Pix DLList::first() +{ + return Pix(h); +} + +inline Pix DLList::last() +{ + return (h == 0)? 0 : Pix(h->bk); +} + +inline & DLList::operator () (Pix p) +{ + if (p == 0) error("null Pix"); + return ((DLListNode*)p)->hd; +} + +inline & DLList::front() +{ + if (h == 0) error("front: empty list"); + return h->hd; +} + +inline & DLList::rear() +{ + if (h == 0) error("rear: empty list"); + return h->bk->hd; +} + + + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/Deque.hP b/usr/src/lib/libg++/g++-include/gen/Deque.hP new file mode 100644 index 0000000000..a82607bec8 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/Deque.hP @@ -0,0 +1,67 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _Deque_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _Deque_h + +#include + +#include ".defs.h" + +class Deque +{ +public: + Deque(); + ~Deque(); + + virtual void push( item) = 0; // insert at front + virtual void enq( item) = 0; // insert at rear + + virtual & front() = 0; + virtual & rear() = 0; + + virtual deq() = 0; + virtual void del_front() = 0; + virtual void del_rear() = 0; + + virtual int empty() = 0; + virtual int full() = 0; + virtual int length() = 0; + virtual void clear() = 0; + + virtual int OK() = 0; + + void error(const char*); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) +inline Deque::Deque() {} +#endif + +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/FPlex.hP b/usr/src/lib/libg++/g++-include/gen/FPlex.hP new file mode 100644 index 0000000000..2fda48d622 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/FPlex.hP @@ -0,0 +1,263 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + +#ifndef _FPlex_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _FPlex_h 1 + +#include ".Plex.h" + +class FPlex : public Plex +{ +public: + FPlex(); // set low = 0; + // fence = 0; + // csize = default + + FPlex(int maxsize); // low = 0; + // fence = 0; + // csize = maxsize + + FPlex(int lo, // low = lo; + int maxsize); // fence=lo + // csize = maxsize + + FPlex(int lo, // low = lo + int hi, // fence = hi+1 + const initval,// fill with initval, + int maxsize = 0); // csize = maxsize + // or fence - lo if 0 + + FPlex(const FPlex&); // X(X&) + + ~FPlex(); + + void operator= (const FPlex&); + +// virtuals + + & high_element (); + & low_element (); + + const & high_element () const; + const & low_element () const; + + Pix first() const; + Pix last() const; + void prev(Pix& ptr) const; + void next(Pix& ptr) const; + int owns(Pix p) const; + & operator () (Pix p); + const & operator () (Pix p) const; + + int low() const; + int high() const; + int valid(int idx) const; + void prev(int& idx) const; + void next(int& x) const; + & operator [] (int index); + const & operator [] (int index) const; + + int Pix_to_index(Pix p) const; + Pix index_to_Pix(int idx) const; + + int can_add_high() const; + int can_add_low() const; + int full() const; + + int add_high(const elem); + int del_high (); + int add_low (const elem); + int del_low (); + + void fill(const x); + void fill(const x, int from, int to); + void clear(); + void reverse(); + void append(const FPlex& a); + void prepend(const FPlex& a); + + int OK () const; +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline int FPlex::valid (int idx) const +{ + return idx >= lo && idx < fnc; +} + +inline int FPlex::low() const +{ + return lo; +} + +inline int FPlex::high() const +{ + return fnc - 1; +} + +inline Pix FPlex::first() const +{ + return (Pix)(hd->IChunk::first_pointer()); +} + +inline void FPlex::prev(Pix& p) const +{ + p = Pix(hd->IChunk::pred((*) p)); +} + +inline void FPlex::next(Pix& p) const +{ + p = Pix(hd->IChunk::succ((*) p)); +} + +inline Pix FPlex::last() const +{ + return Pix(hd->IChunk::last_pointer()); +} + +inline int FPlex::full () const +{ + return fnc - lo == csize; +} + +inline void FPlex::prev(int& idx) const +{ + --idx; +} + +inline void FPlex::next(int& idx) const +{ + ++idx; +} + +inline & FPlex:: operator [] (int idx) +{ + if (idx < lo || idx >= fnc) index_error(); + return *(hd->pointer_to(idx)); +} + +inline & FPlex:: operator () (Pix p) +{ + return *((*)p); +} + +inline & FPlex::low_element () +{ + if (empty()) index_error(); + return *(hd->pointer_to(lo)); +} + +inline & FPlex::high_element () +{ + if (empty()) index_error(); + return *(hd->pointer_to(fnc - 1)); +} + +inline const & FPlex:: operator [] (int idx) const +{ + if (idx < lo || idx >= fnc) index_error(); + return *(hd->pointer_to(idx)); +} + +inline const & FPlex:: operator () (Pix p) const +{ + return *((const *)p); +} + +inline const & FPlex::low_element () const +{ + if (empty()) index_error(); + return *(hd->pointer_to(lo)); +} + +inline const & FPlex::high_element () const +{ + if (empty()) index_error(); + return *(hd->pointer_to(fnc - 1)); +} + +inline int FPlex::can_add_high() const +{ + return hd->can_grow_high(); +} + +inline int FPlex::can_add_low() const +{ + return hd->can_grow_low(); +} + +inline int FPlex::add_high(const elem) +{ + if (!can_add_high()) full_error(); + *((hd->IChunk::grow_high())) = elem; + return fnc++; +} + +inline int FPlex::del_high () +{ + if (empty()) empty_error(); + hd->IChunk::shrink_high(); + return --fnc - 1; +} + +inline int FPlex::add_low (const elem) +{ + if (!can_add_low()) full_error(); + *((hd->IChunk::grow_low())) = elem; + return --lo; +} + +inline int FPlex::del_low () +{ + if (empty()) empty_error(); + hd->IChunk::shrink_low(); + return ++lo; +} + +inline int FPlex::owns (Pix p) const +{ + return hd->actual_pointer((*)p); +} + +inline int FPlex::Pix_to_index(Pix p) const +{ + if (!hd->actual_pointer((const *)p)) index_error(); + return hd->index_of((const *)p); +} + +inline Pix FPlex::index_to_Pix(int idx) const +{ + if (idx < lo || idx >= fnc) index_error(); + return Pix(hd->pointer_to(idx)); +} + +inline FPlex::~FPlex() {} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/List.hP b/usr/src/lib/libg++/g++-include/gen/List.hP new file mode 100644 index 0000000000..cade890d04 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/List.hP @@ -0,0 +1,279 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _List_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _List_h 1 + +#ifndef __typedefs +#define __typedefs 1 +typedef void (*Procedure)(); +typedef (*Mapper)(); +typedef (*Combiner)(, ); +typedef int (*Predicate)(); +typedef int (*Comparator)(, ); +#endif + +#include + +struct ListNode +{ + ListNode* tl; + short ref; + hd; +}; + +extern ListNode NilListNode; + +class List +{ +protected: + ListNode* P; + + List(ListNode* p); +public: + List(); + List( head); + List( head, List& tl); + List(List& a); + List(Pix p); + ~List(); + + List& operator = (List& a); + + int null(); + int valid(); + operator const void* (); + int operator ! (); + + int length(); + int list_length(); + + & get(); + & head(); + & operator [] (int n); + + List nth(int n); + List tail(); + List last(); + + List find( targ); + List find(List& targ); + int contains( targ); + int contains(List& targ); + int position( targ); + + friend List copy(List& a); + friend List concat(List& a, List& b); + friend List append(List& a, List& b); + friend List map(Mapper f, List& a); + friend List merge(List& a, List& b, Comparator f); + friend List combine(Combiner f, List& a, List& b); + friend List reverse(List& a); + friend List select(Predicate f, List& a); + friend List remove( targ, List& a); + friend List remove(Predicate f, List& a); + friend List subst( old, repl, List& a); + + void push( x); + pop(); + + void set_tail(List& p); + void append(List& p); + void prepend(List& p); + void del( targ); + void del(Predicate f); + void select(Predicate f); + void subst( old, repl); + void reverse(); + void sort(Comparator f); + + void apply(Procedure f); + reduce(Combiner f, base); + + friend int operator == (List& a, List& b); + friend int operator != (List& a, List& b); + + Pix first(); + void next(Pix& p); + Pix seek( item); + & operator () (Pix p); + int owns(Pix p); + + void error(const char*); + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline void reference(ListNode* p) +{ + if (p->ref >= 0) ++p->ref; +} + +inline void dereference(ListNode* p) +{ + while (p->ref > 0 && --p->ref == 0) + { + ListNode* n = p->tl; + delete(p); + p = n; + } +} + + +inline ListNode* newListNode( h) +{ + ListNode* p = new ListNode; + p->ref = 1; + p->hd = h; + return p; +} + +inline ListNode* newListNode( h, ListNode* t) +{ + ListNode* p = new ListNode; + p->ref = 1; + p->hd = h; + p->tl = t; + return p; +} + + +inline List::~List() +{ + dereference(P); +} + +inline List::List() +{ + P = &NilListNode; +} + +inline List::List(ListNode* p) +{ + P = p; +} + +inline List::List( head) +{ + P = newListNode(head); + P->tl = &NilListNode; +} + +inline List::List( head, List& tl) +{ + P = newListNode(head, tl.P); + reference(P->tl); +} + +inline List::List(List& a) +{ + reference(a.P); + P = a.P; +} + + +inline & List::get() +{ + return P->hd; +} + +inline & List::head() +{ + return P->hd; +} + + +inline List List::tail() +{ + reference(P->tl); + return List(P->tl); +} + + + +inline int List::null() +{ + return P == &NilListNode; +} + +inline int List::valid() +{ + return P != &NilListNode; +} + +inline List::operator const void* () +{ + return (P == &NilListNode)? 0 : this; +} + +inline int List::operator ! () +{ + return (P == &NilListNode); +} + + +inline void List::push( head) +{ + ListNode* oldp = P; + P = newListNode(head, oldp); +} + + +inline int operator != (List& x, List& y) +{ + return !(x == y); +} + +inline Pix List::first() +{ + return (P == &NilListNode)? 0 : Pix(P); +} + +inline & List::operator () (Pix p) +{ + return ((ListNode*)p)->hd; +} + +inline void List::next(Pix& p) +{ + if (p != 0) + { + p = Pix(((ListNode*)p)->tl); + if (p == &NilListNode) p = 0; + } +} + +inline List::List(Pix p) +{ + P = (ListNode*)p; + reference(P); +} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/Map.hP b/usr/src/lib/libg++/g++-include/gen/Map.hP new file mode 100644 index 0000000000..301a4ab809 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/Map.hP @@ -0,0 +1,96 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _Map_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _Map_h 1 + +#include +#include ".defs.h" + +class Map +{ +protected: + int count; + def; + +public: + Map( dflt); + virtual ~Map(); + + int length(); // current number of items + int empty(); + + virtual int contains( key); // is key mapped? + + virtual void clear(); // delete all items + + virtual & operator [] ( key) = 0; // access contents by key + + virtual void del( key) = 0; // delete entry + + virtual Pix first() = 0; // Pix of first item or 0 + virtual void next(Pix& i) = 0; // advance to next or 0 + virtual & key(Pix i) = 0; // access key at i + virtual & contents(Pix i) = 0; // access contents at i + + virtual int owns(Pix i); // is i a valid Pix ? + virtual Pix seek( key); // Pix of key + + & dflt(); // access default val + + void error(const char* msg); + virtual int OK() = 0; // rep invariant +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline Map::~Map() {} + +inline int Map::length() +{ + return count; +} + +inline int Map::empty() +{ + return count == 0; +} + +inline & Map::dflt() +{ + return def; +} + +inline Map::Map( dflt) :def(dflt) +{ + count = 0; +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/OSLBag.hP b/usr/src/lib/libg++/g++-include/gen/OSLBag.hP new file mode 100644 index 0000000000..36d74bcb9e --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/OSLBag.hP @@ -0,0 +1,100 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _OSLBag_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _OSLBag_h 1 + +#include ".Bag.h" +#include ".SLList.h" + +class OSLBag : public Bag +{ +protected: + SLList p; + +public: + OSLBag(); + OSLBag(const OSLBag&); + + Pix add( item); + void del( item); + void remove(item); + + int contains( item); + int nof( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + int owns(Pix i); + Pix seek( item, Pix from = 0); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline OSLBag::OSLBag() : p() { count = 0; } + +inline OSLBag::OSLBag(const OSLBag& s) : p(s.p) { count = s.count; } + +inline Pix OSLBag::first() +{ + return p.first(); +} + +inline void OSLBag::next(Pix & idx) +{ + p.next(idx); +} + +inline & OSLBag::operator ()(Pix idx) +{ + return p(idx); +} + +inline void OSLBag::clear() +{ + count = 0; p.clear(); +} + +inline int OSLBag::owns (Pix idx) +{ + return p.owns(idx); +} + +inline int OSLBag::contains( item) +{ + return seek(item) != 0; +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/OSLSet.hP b/usr/src/lib/libg++/g++-include/gen/OSLSet.hP new file mode 100644 index 0000000000..1e94c09efc --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/OSLSet.hP @@ -0,0 +1,109 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _OSLSet_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _OSLSet_h 1 + +#include ".Set.h" +#include ".SLList.h" + +class OSLSet : public Set +{ +protected: + SLList p; + +public: + OSLSet(); + OSLSet(const OSLSet&); + + Pix add( item); + void del( item); + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + int owns(Pix i); + Pix seek( item); + + void operator |= (OSLSet& b); + void operator -= (OSLSet& b); + void operator &= (OSLSet& b); + + int operator == (OSLSet& b); + int operator != (OSLSet& b); + int operator <= (OSLSet& b); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline OSLSet::OSLSet() : p() { count = 0; } + +inline OSLSet::OSLSet(const OSLSet& s) : p(s.p) { count = s.count; } + +inline Pix OSLSet::first() +{ + return p.first(); +} + +inline void OSLSet::next(Pix & idx) +{ + p.next(idx); +} + +inline & OSLSet::operator ()(Pix idx) +{ + return p(idx); +} + +inline void OSLSet::clear() +{ + count = 0; p.clear(); +} + +inline int OSLSet::contains ( item) +{ + return seek(item) != 0; +} + +inline int OSLSet::owns (Pix idx) +{ + return p.owns(idx); +} + +inline int OSLSet::operator != (OSLSet& b) +{ + return !(*this == b); +} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/OXPBag.hP b/usr/src/lib/libg++/g++-include/gen/OXPBag.hP new file mode 100644 index 0000000000..5542a273dc --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/OXPBag.hP @@ -0,0 +1,76 @@ +#ifndef _OXPBag_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _OXPBag_h 1 + +#include ".Bag.h" +#include ".XPlex.h" + +class OXPBag : public Bag +{ +protected: + XPlex p; + +public: + OXPBag(int chunksize = DEFAULT_INITIAL_CAPACITY); + OXPBag(const OXPBag&); + + Pix add( item); + void del( item); + void remove(item); + int nof( item); + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + int owns(Pix i); + Pix seek( item, Pix from = 0); + + int OK(); +}; + + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline OXPBag::OXPBag(int chunksize) + : p(chunksize) { count = 0; } + +inline OXPBag::OXPBag(const OXPBag& s) : p(s.p) { count = s.count; } + +inline Pix OXPBag::first() +{ + return p.first(); +} + +inline void OXPBag::next(Pix & idx) +{ + p.next(idx); +} + +inline & OXPBag::operator ()(Pix idx) +{ + return p(idx); +} + +inline void OXPBag::clear() +{ + count = 0; p.clear(); +} + +inline int OXPBag::owns (Pix idx) +{ + return p.owns(idx); +} + +inline int OXPBag::contains( item) +{ + return seek(item) != 0; +} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/OXPSet.hP b/usr/src/lib/libg++/g++-include/gen/OXPSet.hP new file mode 100644 index 0000000000..fb1cb3c4fa --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/OXPSet.hP @@ -0,0 +1,110 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _OXPSet_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _OXPSet_h 1 + +#include ".Set.h" +#include ".XPlex.h" + +class OXPSet : public Set +{ +protected: + XPlex p; + +public: + OXPSet(int chunksize = DEFAULT_INITIAL_CAPACITY); + OXPSet(const OXPSet&); + + Pix add( item); + void del( item); + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + int owns(Pix i); + Pix seek( item); + + void operator |= (OXPSet& b); + void operator -= (OXPSet& b); + void operator &= (OXPSet& b); + + int operator == (OXPSet& b); + int operator != (OXPSet& b); + int operator <= (OXPSet& b); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline OXPSet::OXPSet(int chunksize) + : p(chunksize) { count = 0; } + +inline OXPSet::OXPSet(const OXPSet& s) : p(s.p) { count = s.count; } + +inline Pix OXPSet::first() +{ + return p.first(); +} + +inline void OXPSet::next(Pix & idx) +{ + p.next(idx); +} + +inline & OXPSet::operator ()(Pix idx) +{ + return p(idx); +} + +inline void OXPSet::clear() +{ + count = 0; p.clear(); +} + +inline int OXPSet::contains ( item) +{ + return seek(item) != 0; +} + +inline int OXPSet::owns (Pix idx) +{ + return p.owns(idx); +} + +inline int OXPSet::operator != (OXPSet& b) +{ + return !(*this == b); +} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/PHPQ.hP b/usr/src/lib/libg++/g++-include/gen/PHPQ.hP new file mode 100644 index 0000000000..acc6ebb298 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/PHPQ.hP @@ -0,0 +1,118 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Dirk Grunwald (grunwald@cs.uiuc.edu) + adapted for libg++ by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + +#ifndef PHPQ_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define PHPQ_h 1 + +#include ".PQ.h" + +#ifndef PHPQIndex +#define PHPQIndex unsigned short +#endif + +struct PHPQNode +{ + PHPQIndex sibling; + PHPQIndex children; + item; + char valid; +}; + + +class PHPQ : public PQ +{ + PHPQNode* storage; // table -- freelist in storage[0].sibling + int root; + int size; + + void prealloc(int); + int check_sibling_list(int, int); + +public: + + PHPQ(int sz = DEFAULT_INITIAL_CAPACITY); + PHPQ(PHPQ&); + ~PHPQ(); + + Pix enq( item); + deq(); + + & front(); + void del_front(); + + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + void del(Pix i); + Pix seek( item); + + int OK(); // rep invariant +}; + + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline PHPQ::~PHPQ() +{ + delete [size] storage; +} + + +inline PHPQ::deq() +{ + if (count == 0) error("deq of empty PQ"); + x = storage[root].item; + del_front(); + return x; +} + + +inline & PHPQ::front() +{ + if (count == 0) error("front of empty PQ"); + return storage[root].item; +} + +inline int PHPQ::contains( item) +{ + return seek(item) != 0; +} + +inline & PHPQ::operator() (Pix p) +{ + if (p == 0) error("null Pix"); + return storage[int(p)].item; +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/Plex.hP b/usr/src/lib/libg++/g++-include/gen/Plex.hP new file mode 100644 index 0000000000..38a1ef6667 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/Plex.hP @@ -0,0 +1,503 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + +#ifndef _Plex_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _Plex_h 1 + +#include +#include +#include ".defs.h" + +// Plexes are made out of IChunks + +#include + +class IChunk +{ +//public: // kludge until C++ `protected' policies settled +protected: + + * data; // data, from client + + int base; // lowest possible index + int low; // lowest valid index + int fence; // highest valid index + 1 + int top; // highest possible index + 1 + + IChunk* nxt; // circular links + IChunk* prv; + +public: + +// constructors + + IChunk(* d, // ptr to array of elements + int base_idx, // initial indices + int low_idx, + int fence_idx, + int top_idx); + + virtual ~IChunk(); + +// status reports + + int size() const; // number of slots + + virtual int empty() const ; + virtual int full() const ; + + int can_grow_high () const ; // there is space to add data + int can_grow_low () const; + + int base_index() const; // lowest possible index; + int low_index() const; // lowest actual index; + virtual int first_index() const; // lowest valid index or fence if none + virtual int last_index() const; // highest valid index or low-1 if none + int fence_index() const; // highest actual index + 1 + int top_index() const; // highest possible index + 1 + +// indexing conversion + + int possible_index(int i) const; // i between base and top + int actual_index(int i) const; // i between low and fence + virtual int valid_index(int i) const; // i not deleted (mainly for mchunks) + + int possible_pointer(const * p) const; // same for ptr + int actual_pointer(const * p) const; + virtual int valid_pointer(const * p) const; + + * pointer_to(int i) const ; // pointer to data indexed by i + // caution: i is not checked for validity + int index_of(const * p) const; // index of data pointed to by p + // caution: p is not checked for validity + + virtual int succ(int idx) const; // next valid index or fence if none + virtual int pred(int idx) const; // previous index or low - 1 if none + + virtual * first_pointer() const; // pointer to first valid pos or 0 + virtual * last_pointer() const; // pointer to first valid pos or 0 + virtual * succ(* p) const; // next pointer or 0 + virtual * pred(* p) const; // previous pointer or 0 + +// modification + + virtual * grow_high (); // return spot to add an element + virtual * grow_low (); + + virtual void shrink_high (); // logically delete top index + virtual void shrink_low (); + + virtual void clear(int lo); // reset to empty ch with base = lo + virtual void cleardown(int hi); // reset to empty ch with top = hi + void re_index(int lo); // re-index so lo is new low + +// chunk traversal + + IChunk* next() const; + IChunk* prev() const; + + void link_to_prev(IChunk* prev); + void link_to_next(IChunk* next); + void unlink(); + +// state checks + + * invalidate(); // mark self as invalid; return data + // for possible deletion + + virtual int OK() const; // representation invariant + + volatile void error(const char*) const; + volatile void empty_error() const; + volatile void full_error() const; + volatile void index_error() const; +}; + +// Plex is a partly `abstract' class: few of the virtuals +// are implemented at the Plex level, only in the subclasses + +class Plex +{ +protected: + + IChunk* hd; // a chunk holding the data + int lo; // lowest index + int fnc; // highest index + 1 + int csize; // size of the chunk + + void invalidate(); // mark so OK() is false + void del_chunk(IChunk*); // delete a chunk + + IChunk* tl() const; // last chunk; + int one_chunk() const; // true if hd == tl() + +public: + +// constructors, etc. + + Plex(); // no-op + + virtual ~Plex(); + + +// Access functions + + virtual & operator [] (int idx) = 0; // access by index; + virtual & operator () (Pix p) = 0; // access by Pix; + + virtual & high_element () = 0; // access high element + virtual & low_element () = 0; // access low element + +// read-only versions for const Plexes + + virtual const & operator [] (int idx) const = 0; // access by index; + virtual const & operator () (Pix p) const = 0; // access by Pix; + + virtual const & high_element () const = 0; // access high element + virtual const & low_element () const = 0; // access low element + + +// Index functions + + virtual int valid (int idx) const = 0; // idx is an OK index + + virtual int low() const = 0; // lowest index or fence if none + virtual int high() const = 0; // highest index or low-1 if none + + int ecnef() const; // low limit index (low-1) + int fence() const; // high limit index (high+1) + + virtual void prev(int& idx) const= 0; // set idx to preceding index + // caution: pred may be out of bounds + + virtual void next(int& idx) const = 0; // set to next index + // caution: succ may be out of bounds + + virtual Pix first() const = 0; // Pix to low element or 0 + virtual Pix last() const = 0; // Pix to high element or 0 + virtual void prev(Pix& pix) const = 0; // preceding pix or 0 + virtual void next(Pix& pix) const = 0; // next pix or 0 + virtual int owns(Pix p) const = 0; // p is an OK Pix + +// index<->Pix + + virtual int Pix_to_index(Pix p) const = 0; // get index via Pix + virtual Pix index_to_Pix(int idx) const = 0; // Pix via index + +// Growth + + virtual int add_high(const elem) =0;// add new element at high end + // return new high + + virtual int add_low(const elem) = 0; // add new low element, + // return new low + +// Shrinkage + + virtual int del_high() = 0; // remove the element at high end + // return new high + virtual int del_low() = 0; // delete low element, return new lo + + // caution: del_low/high + // does not necessarily + // immediately call ::~ + + +// operations on multiple elements + + virtual void fill(const x); // set all elements = x + virtual void fill(const x, int from, int to); // fill from to to + virtual void clear() = 0; // reset to zero-sized Plex + virtual int reset_low(int newlow); // change low index,return old + virtual void reverse(); // reverse in-place + virtual void append(const Plex& a); // concatenate a copy + virtual void prepend(const Plex& a); // prepend a copy + +// status + + virtual int can_add_high() const = 0; + virtual int can_add_low() const = 0; + + int length () const; // number of slots + + int empty () const; // is the plex empty? + virtual int full() const = 0; // it it full? + + int chunk_size() const; // report chunk size; + + virtual int OK() const = 0; // representation invariant + + volatile void error(const char* msg) const; + volatile void index_error() const; + volatile void empty_error() const; + volatile void full_error() const; +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +// IChunk ops + +inline int IChunk:: size() const +{ + return top - base; +} + + +inline int IChunk:: base_index() const +{ + return base; +} + +inline int IChunk:: low_index() const +{ + return low; +} + +inline int IChunk:: fence_index() const +{ + return fence; +} + +inline int IChunk:: top_index() const +{ + return top; +} + +inline * IChunk:: pointer_to(int i) const +{ + return &(data[i-base]); +} + +inline int IChunk:: index_of(const * p) const +{ + return ((int)p - (int)data) / sizeof() + base; +} + +inline int IChunk:: possible_index(int i) const +{ + return i >= base && i < top; +} + +inline int IChunk:: possible_pointer(const * p) const +{ + return p >= data && p < &(data[top-base]); +} + +inline int IChunk:: actual_index(int i) const +{ + return i >= low && i < fence; +} + +inline int IChunk:: actual_pointer(const * p) const +{ + return p >= data && p < &(data[fence-base]); +} + +inline int IChunk:: can_grow_high () const +{ + return fence < top; +} + +inline int IChunk:: can_grow_low () const +{ + return base < low; +} + +inline * IChunk:: invalidate() +{ + * p = data; + data = 0; + return p; +} + + +inline IChunk* IChunk::prev() const +{ + return prv; +} + +inline IChunk* IChunk::next() const +{ + return nxt; +} + +inline void IChunk::link_to_prev(IChunk* prev) +{ + nxt = prev->nxt; + prv = prev; + nxt->prv = this; + prv->nxt = this; +} + +inline void IChunk::link_to_next(IChunk* next) +{ + prv = next->prv; + nxt = next; + nxt->prv = this; + prv->nxt = this; +} + +inline void IChunk::unlink() +{ + IChunk* n = nxt; + IChunk* p = prv; + n->prv = p; + p->nxt = n; + prv = nxt = this; +} + +inline int IChunk:: empty() const +{ + return low == fence; +} + +inline int IChunk:: full() const +{ + return top - base == fence - low; +} + +inline int IChunk:: first_index() const +{ + return (low == fence)? fence : low; +} + +inline int IChunk:: last_index() const +{ + return (low == fence)? low - 1 : fence - 1; +} + +inline int IChunk:: succ(int i) const +{ + return (i < low) ? low : i + 1; +} + +inline int IChunk:: pred(int i) const +{ + return (i > fence) ? (fence - 1) : i - 1; +} + +inline int IChunk:: valid_index(int i) const +{ + return i >= low && i < fence; +} + +inline int IChunk:: valid_pointer(const * p) const +{ + return p >= &(data[low - base]) && p < &(data[fence - base]); +} + +inline * IChunk:: grow_high () +{ + if (!can_grow_high()) full_error(); + return &(data[fence++ - base]); +} + +inline * IChunk:: grow_low () +{ + if (!can_grow_low()) full_error(); + return &(data[--low - base]); +} + +inline void IChunk:: shrink_high () +{ + if (empty()) empty_error(); + --fence; +} + +inline void IChunk:: shrink_low () +{ + if (empty()) empty_error(); + ++low; +} + +inline * IChunk::first_pointer() const +{ + return (low == fence)? 0 : &(data[low - base]); +} + +inline * IChunk::last_pointer() const +{ + return (low == fence)? 0 : &(data[fence - base - 1]); +} + +inline * IChunk::succ(* p) const +{ + return ((p+1) < &(data[low - base]) || (p+1) >= &(data[fence - base])) ? + 0 : (p+1); +} + +inline * IChunk::pred(* p) const +{ + return ((p-1) < &(data[low - base]) || (p-1) >= &(data[fence - base])) ? + 0 : (p-1); +} + + +// generic Plex operations + +inline Plex::Plex() {} + +inline int Plex::chunk_size() const +{ + return csize; +} + +inline int Plex::ecnef () const +{ + return lo - 1; +} + + +inline int Plex::fence () const +{ + return fnc; +} + +inline int Plex::length () const +{ + return fnc - lo; +} + +inline int Plex::empty () const +{ + return fnc == lo; +} + +inline IChunk* Plex::tl() const +{ + return hd->prev(); +} + +inline int Plex::one_chunk() const +{ + return hd == hd->prev(); +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/Queue.hP b/usr/src/lib/libg++/g++-include/gen/Queue.hP new file mode 100644 index 0000000000..3ff62c865c --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/Queue.hP @@ -0,0 +1,62 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _Queue_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _Queue_h + +#include + +#include ".defs.h" + +class Queue +{ +public: + Queue(); + virtual ~Queue(); + + virtual void enq( item) = 0; + virtual deq() = 0; + virtual & front() = 0; + virtual void del_front() = 0; + + virtual void clear() = 0; + virtual int empty() = 0; + virtual int full() = 0; + virtual int length() = 0; + + void error(const char*); + + virtual int OK() = 0; +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline Queue::Queue() {} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/RAVLMap.hP b/usr/src/lib/libg++/g++-include/gen/RAVLMap.hP new file mode 100644 index 0000000000..cf216e5ba0 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/RAVLMap.hP @@ -0,0 +1,162 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + ranking code from Paul Anderson (paul%lfcs.ed.ac.uk) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _RAVLMap_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _RAVLMap_h 1 + +#include "..Map.h" + +struct RAVLNode +{ + RAVLNode* lt; + RAVLNode* rt; + item; + cont; + int rank; + char stat; + RAVLNode( h, c, + RAVLNode* l=0, RAVLNode* r=0, int k=1); + ~RAVLNode(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline RAVLNode::RAVLNode( h, c, + RAVLNode* l, RAVLNode* r, int k) + :item(h), cont(c), lt(l), rt(r), rank(k), stat(0) {} + +inline RAVLNode::~RAVLNode() {} + +#endif + +typedef RAVLNode* RAVLNodePtr; + + +class RAVLMap : public Map +{ +protected: + RAVLNode* root; + + RAVLNode* leftmost(); + RAVLNode* rightmost(); + RAVLNode* pred(RAVLNode* t); + RAVLNode* succ(RAVLNode* t); + void _kill(RAVLNode* t); + void _add(RAVLNode*& t); + void _del(RAVLNode* p, RAVLNode*& t); + +public: + RAVLMap( dflt); + RAVLMap(RAVLMap& a); + ~RAVLMap(); + + & operator [] ( key); + + void del( key); + + Pix first(); + void next(Pix& i); + & key(Pix i); + & contents(Pix i); + + Pix seek( key); + int contains( key); + + Pix ranktoPix(int i); + int rankof( key); + + void clear(); + + Pix last(); + void prev(Pix& i); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline RAVLMap::~RAVLMap() +{ + _kill(root); +} + +inline RAVLMap::RAVLMap( dflt) :(dflt) +{ + root = 0; +} + + +inline Pix RAVLMap::first() +{ + return Pix(leftmost()); +} + +inline Pix RAVLMap::last() +{ + return Pix(rightmost()); +} + +inline void RAVLMap::next(Pix& i) +{ + if (i != 0) i = Pix(succ((RAVLNode*)i)); +} + +inline void RAVLMap::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((RAVLNode*)i)); +} + +inline & RAVLMap::key(Pix i) +{ + if (i == 0) error("null Pix"); + return ((RAVLNode*)i)->item; +} + +inline & RAVLMap::contents(Pix i) +{ + if (i == 0) error("null Pix"); + return ((RAVLNode*)i)->cont; +} + +inline void RAVLMap::clear() +{ + _kill(root); + count = 0; + root = 0; +} + +inline int RAVLMap::contains( key) +{ + return seek(key) != 0; +} + + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/RPlex.hP b/usr/src/lib/libg++/g++-include/gen/RPlex.hP new file mode 100644 index 0000000000..7a21f5bb64 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/RPlex.hP @@ -0,0 +1,268 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + +#ifndef _RPlex_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _RPlex_h 1 + +#include ".Plex.h" + +// minimum number of chunks to index + +#ifndef MIN_NCHUNKS +#define MIN_NCHUNKS 16 +#endif + +class RPlex: public Plex +{ + int base; // base index of lowest chunk + int lch; // index of lowest used chunk + int fch; // 1 + index of highest used chunk + int maxch; // max chunks in array + IChunk** chunks; // array of chunks + IChunk* ch; // cached chunk + + void make_initial_chunks(int up = 1); + + void cache(int idx) const; + void cache(const * p) const; + * dopred(const * p) const; + * dosucc(const * p) const; + + void set_cache(const IChunk* t) const; // logically, + // not physically const + +public: + RPlex(); // set low = 0; + // fence = 0; + // csize = default + + RPlex(int ch_size); // low = 0; + // fence = 0; + // csize = ch_size + + RPlex(int lo, // low = lo; + int ch_size); // fence=lo + // csize = ch_size + + RPlex(int lo, // low = lo + int hi, // fence = hi+1 + const initval,// fill with initval, + int ch_size = 0); // csize= ch_size + // or fence-lo if 0 + + RPlex(const RPlex&); + + ~RPlex(); + + void operator= (const RPlex&); + +// virtuals + + & high_element (); + & low_element (); + + const & high_element () const; + const & low_element () const; + + Pix first() const; + Pix last() const; + void prev(Pix& ptr) const; + void next(Pix& ptr) const; + int owns(Pix p) const; + & operator () (Pix p); + const & operator () (Pix p) const; + + int low() const; + int high() const; + int valid(int idx) const; + void prev(int& idx) const; + void next(int& x) const; + & operator [] (int index); + const & operator [] (int index) const; + + int Pix_to_index(Pix p) const; + Pix index_to_Pix(int idx) const; + + int can_add_high() const; + int can_add_low() const; + int full() const; + + int add_high(const elem); + int del_high (); + int add_low (const elem); + int del_low (); + + void fill(const x); + void fill(const x, int from, int to); + void clear(); + void reverse(); + void append(const RPlex& a); + void prepend(const RPlex& a); + + int reset_low(int newlow); + + int OK () const; +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline void RPlex::prev(int& idx) const +{ + --idx; +} + +inline void RPlex::next(int& idx) const +{ + ++idx; +} + +inline int RPlex::full () const +{ + return 0; +} + +inline int RPlex::can_add_high() const +{ + return 1; +} + +inline int RPlex::can_add_low() const +{ + return 1; +} + +inline int RPlex::valid (int idx) const +{ + return idx >= lo && idx < fnc; +} + +inline int RPlex::low() const +{ + return lo; +} + +inline int RPlex::high() const +{ + return fnc - 1; +} + +inline void RPlex::set_cache(const IChunk* t) const +{ + ((RPlex*)(this))->ch = (IChunk*)t; +} + +inline void RPlex::cache(int idx) const +{ + if (idx < lo || idx >= fnc) index_error(); + set_cache(chunks[(idx - base) / csize]); +} + +inline & RPlex::low_element () +{ + cache(lo); return *(ch->pointer_to(lo)); +} + +inline & RPlex::high_element () +{ + cache(fnc-1); return *(ch->pointer_to(fnc - 1)); +} + +inline const & RPlex::low_element () const +{ + cache(lo); return *((const *)(ch->pointer_to(lo))); +} + +inline const & RPlex::high_element () const +{ + cache(fnc-1); return *((const *)(ch->pointer_to(fnc - 1))); +} + +inline int RPlex::Pix_to_index(Pix px) const +{ + * p = (*)px; + if (!ch->actual_pointer(p)) cache(p); + return ch->index_of(p); +} + +inline Pix RPlex::index_to_Pix(int idx) const +{ + if (!ch->actual_index(idx)) cache(idx); + return (Pix)(ch->pointer_to(idx)); +} + +inline Pix RPlex::first() const +{ + return Pix(hd->IChunk::first_pointer()); +} + +inline Pix RPlex::last() const +{ + return Pix(tl()->IChunk::last_pointer()); +} + +inline void RPlex::prev(Pix& p) const +{ + Pix q = Pix(ch->IChunk::pred((*)p)); + p = (q == 0)? Pix(dopred((*)p)) : q; +} + +inline void RPlex::next(Pix& p) const +{ + Pix q = Pix(ch->IChunk::succ((*)p)); + p = (q == 0)? Pix(dosucc((*)p)) : q; +} + +inline & RPlex:: operator () (Pix p) +{ + return *((*)p); +} + + +inline & RPlex:: operator [] (int idx) +{ + cache(idx); return *(ch->pointer_to(idx)); +} + +inline const & RPlex:: operator () (Pix p) const +{ + return *((const *)p); +} + +inline const & RPlex:: operator [] (int idx) const +{ + cache(idx); return *((const *)(ch->pointer_to(idx))); +} + +inline RPlex::~RPlex() +{ + delete chunks; +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/SLBag.hP b/usr/src/lib/libg++/g++-include/gen/SLBag.hP new file mode 100644 index 0000000000..d039241668 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/SLBag.hP @@ -0,0 +1,104 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _SLBag_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _SLBag_h 1 + +#include ".Bag.h" +#include ".SLList.h" + +class SLBag : public Bag +{ +protected: + SLList p; + +public: + SLBag(); + SLBag(const SLBag&); + + Pix add( item); + void del( item); + void remove(item); + int contains( item); + int nof( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + int owns(Pix i); + Pix seek( item, Pix from = 0); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline SLBag::SLBag() : p() { count = 0; } + +inline SLBag::SLBag(const SLBag& s) : p(s.p) { count = s.count; } + +inline Pix SLBag::first() +{ + return p.first(); +} + +inline void SLBag::next(Pix & idx) +{ + p.next(idx); +} + +inline & SLBag::operator ()(Pix idx) +{ + return p(idx); +} + +inline void SLBag::clear() +{ + count = 0; p.clear(); +} + +inline int SLBag::owns (Pix idx) +{ + return p.owns(idx); +} + +inline Pix SLBag::add( item) +{ + ++count; + return p.append(item); +} + +inline int SLBag::contains( item) +{ + return seek(item) != 0; +} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/SLList.hP b/usr/src/lib/libg++/g++-include/gen/SLList.hP new file mode 100644 index 0000000000..1886b68f1a --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/SLList.hP @@ -0,0 +1,152 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _SLList_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _SLList_h 1 + +#include +#include ".defs.h" + +#ifndef _SLListNode_h +#define _SLListNode_h 1 + +struct SLListNode +{ + SLListNode* tl; + hd; + SLListNode(); + SLListNode( h, SLListNode* t = 0); + ~SLListNode(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline SLListNode::SLListNode() {} + +inline SLListNode::SLListNode( h, SLListNode* t) :hd(h), tl(t) {} + +inline SLListNode::~SLListNode() {} + +#endif + +typedef SLListNode* SLListNodePtr; + +#endif + + +class SLList +{ +protected: + SLListNode* last; + +public: + SLList(); + SLList(SLList& a); + ~SLList(); + + SLList& operator = (SLList& a); + + int empty(); + int length(); + + void clear(); + + Pix prepend( item); + Pix append( item); + + void join(SLList&); + + Pix prepend(SLListNode*); + Pix append(SLListNode*); + + & operator () (Pix p); + Pix first(); + void next(Pix& p); + int owns(Pix p); + Pix ins_after(Pix p, item); + void del_after(Pix p); + + & front(); + & rear(); + remove_front(); + int remove_front(& x); + void del_front(); + + void error(const char* msg); + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline SLList::~SLList() +{ + clear(); +} + +inline SLList::SLList() +{ + last = 0; +} + +inline int SLList::empty() +{ + return last == 0; +} + + +inline Pix SLList::first() +{ + return (last == 0)? 0 : Pix(last->tl); +} + +inline void SLList::next(Pix& p) +{ + p = (p == 0 || p == last)? 0 : Pix(((SLListNode*)(p))->tl); +} + +inline & SLList::operator () (Pix p) +{ + if (p == 0) error("null Pix"); + return ((SLListNode*)(p))->hd; +} + +inline & SLList::front() +{ + if (last == 0) error("front: empty list"); + return last->tl->hd; +} + +inline & SLList::rear() +{ + if (last == 0) error("rear: empty list"); + return last->hd; +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/SLQueue.hP b/usr/src/lib/libg++/g++-include/gen/SLQueue.hP new file mode 100644 index 0000000000..5e75031d3d --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/SLQueue.hP @@ -0,0 +1,118 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + +#ifndef _SLQueue_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _SLQueue_h + +#include ".SLList.h" +#include ".Queue.h" + +class SLQueue : public Queue +{ + SLList p; + +public: + SLQueue(); + SLQueue(const SLQueue& q); + ~SLQueue(); + + void operator = (const SLQueue&); + + void enq( item); + deq(); + & front(); + void del_front(); + + void clear(); + int empty(); + int full(); + int length(); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline SLQueue::SLQueue() :p() {} +inline SLQueue::SLQueue(const SLQueue& q) : p(q.p) {} + +inline SLQueue::~SLQueue() {} + +inline void SLQueue::enq(item) +{ + p.append(item); +} + +inline SLQueue::deq() +{ + return p.remove_front(); +} + +inline & SLQueue::front() +{ + return p.front(); +} + + +inline void SLQueue::del_front() +{ + p.del_front(); +} + +inline void SLQueue::operator =(const SLQueue& s) +{ + p = s.p; +} + +inline int SLQueue::empty() +{ + return p.empty(); +} + +inline int SLQueue::full() +{ + return 0; +} + +inline int SLQueue::length() +{ + return p.length(); +} + +inline int SLQueue::OK() +{ + return p.OK(); +} + +inline void SLQueue::clear() +{ + p.clear(); +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/SLSet.hP b/usr/src/lib/libg++/g++-include/gen/SLSet.hP new file mode 100644 index 0000000000..bc11a74c04 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/SLSet.hP @@ -0,0 +1,97 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _SLSet_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _SLSet_h 1 + +#include ".Set.h" +#include ".SLList.h" + +class SLSet : public Set +{ +protected: + SLList p; + +public: + SLSet(); + SLSet(const SLSet&); + + Pix add( item); + void del( item); + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + int owns(Pix i); + Pix seek( item); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline SLSet::SLSet() : p() { count = 0; } + +inline SLSet::SLSet(const SLSet& s) : p(s.p) { count = s.count; } + +inline Pix SLSet::first() +{ + return p.first(); +} + +inline void SLSet::next(Pix & idx) +{ + p.next(idx); +} + +inline & SLSet::operator ()(Pix idx) +{ + return p(idx); +} + +inline void SLSet::clear() +{ + count = 0; p.clear(); +} + +inline int SLSet::contains ( item) +{ + return seek(item) != 0; +} + +inline int SLSet::owns (Pix idx) +{ + return p.owns(idx); +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/SLStack.hP b/usr/src/lib/libg++/g++-include/gen/SLStack.hP new file mode 100644 index 0000000000..dced467206 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/SLStack.hP @@ -0,0 +1,119 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _SLStack_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _SLStack_h 1 + +#include ".SLList.h" +#include ".Stack.h" + +class SLStack : public Stack +{ + SLList p; + +public: + SLStack(); + SLStack(const SLStack& s); + ~SLStack(); + + void operator = (const SLStack&); + + void push( item); + pop(); + & top(); + void del_top(); + + int empty(); + int full(); + int length(); + + void clear(); + + int OK(); + +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline SLStack::SLStack() :p() {} +inline SLStack::SLStack(const SLStack& a) : p(a.p) {} +inline SLStack::~SLStack() {} + +inline void SLStack::push( item) +{ + p.prepend(item); +} + +inline SLStack::pop() +{ + return p.remove_front(); +} + +inline & SLStack::top() +{ + return p.front(); +} + +inline void SLStack::del_top() +{ + p.del_front(); +} + +inline void SLStack::operator =(const SLStack& s) +{ + p = s.p; +} + +inline int SLStack::empty() +{ + return p.empty(); +} + +inline int SLStack::full() +{ + return 0; +} + +inline int SLStack::length() +{ + return p.length(); +} + +inline int SLStack::OK() +{ + return p.OK(); +} + +inline void SLStack::clear() +{ + p.clear(); +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/Set.hP b/usr/src/lib/libg++/g++-include/gen/Set.hP new file mode 100644 index 0000000000..b2c08cea00 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/Set.hP @@ -0,0 +1,88 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _Set_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _Set_h 1 + +#include +#include ".defs.h" + +class Set +{ +protected: + + int count; + +public: + virtual ~Set(); + + int length(); // current number of items + int empty(); + + virtual Pix add( item) = 0; // add item; return Pix + virtual void del( item) = 0; // delete item + virtual int contains( item); // is item in set? + + virtual void clear(); // delete all items + + virtual Pix first() = 0; // Pix of first item or 0 + virtual void next(Pix& i) = 0; // advance to next or 0 + virtual & operator () (Pix i) = 0; // access item at i + + virtual int owns(Pix i); // is i a valid Pix ? + virtual Pix seek( item); // Pix of item + + void operator |= (Set& b); // add all items in b + void operator -= (Set& b); // delete items also in b + void operator &= (Set& b); // delete items not in b + + int operator == (Set& b); + int operator != (Set& b); + int operator <= (Set& b); + + void error(const char* msg); + virtual int OK() = 0; // rep invariant +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline Set::~Set() {} + +inline int Set::length() +{ + return count; +} + +inline int Set::empty() +{ + return count == 0; +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/SplayBag.hP b/usr/src/lib/libg++/g++-include/gen/SplayBag.hP new file mode 100644 index 0000000000..5d3723ba9c --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/SplayBag.hP @@ -0,0 +1,160 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _SplayBag_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _SplayBag_h 1 + +#include ".Bag.h" + +#ifndef _SplayNode +#define _SplayNode 1 + +struct SplayNode +{ + SplayNode* lt; + SplayNode* rt; + SplayNode* par; + item; + SplayNode( h, SplayNode* l=0, SplayNode* r=0); + ~SplayNode(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline SplayNode::SplayNode( h, SplayNode* l, SplayNode* r) +:item(h), lt(l), rt(r), par(0) {} + +inline SplayNode::~SplayNode() {} + +#endif + +typedef SplayNode* SplayNodePtr; + +#endif + +class SplayBag : public Bag +{ +protected: + SplayNode* root; + + SplayNode* leftmost(); + SplayNode* rightmost(); + SplayNode* pred(SplayNode* t); + SplayNode* succ(SplayNode* t); + void _kill(SplayNode* t); + SplayNode* _copy(SplayNode* t); + void _del(SplayNode* t); + +public: + SplayBag(); + SplayBag(SplayBag& a); + ~SplayBag(); + + Pix add( item); + void del( item); + void remove(item); + int nof( item); + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + Pix seek( item, Pix from = 0); + + Pix last(); + void prev(Pix& i); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline SplayBag::~SplayBag() +{ + _kill(root); +} + +inline SplayBag::SplayBag() +{ + root = 0; + count = 0; +} + +inline SplayBag::SplayBag(SplayBag& b) +{ + count = b.count; + root = _copy(b.root); +} + +inline Pix SplayBag::first() +{ + return Pix(leftmost()); +} + +inline Pix SplayBag::last() +{ + return Pix(rightmost()); +} + +inline void SplayBag::next(Pix& i) +{ + if (i != 0) i = Pix(succ((SplayNode*)i)); +} + +inline void SplayBag::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((SplayNode*)i)); +} + +inline & SplayBag::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return ((SplayNode*)i)->item; +} + +inline void SplayBag::clear() +{ + _kill(root); + count = 0; + root = 0; +} + +inline int SplayBag::contains( key) +{ + return seek(key) != 0; +} + +inline void SplayBag::del( key) +{ + _del((SplayNode*)(seek(key))); +} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/SplayMap.hP b/usr/src/lib/libg++/g++-include/gen/SplayMap.hP new file mode 100644 index 0000000000..39cbe12be5 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/SplayMap.hP @@ -0,0 +1,166 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _SplayMap_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _SplayMap_h 1 + +#include "..Map.h" + +#ifndef _SplayNode +#define _SplayNode 1 + +struct SplayNode +{ + SplayNode* lt; + SplayNode* rt; + SplayNode* par; + item; + cont; + SplayNode( h, c, + SplayNode* l=0, + SplayNode* r=0); + ~SplayNode(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline SplayNode::SplayNode( h, c, + SplayNode* l, + SplayNode* r) + :item(h), cont(c), lt(l), rt(r), par(0) {} + +inline SplayNode::~SplayNode() {} + +#endif + +typedef SplayNode* SplayNodePtr; + +#endif + +class SplayMap : public Map +{ +protected: + SplayNode* root; + + SplayNode* leftmost(); + SplayNode* rightmost(); + SplayNode* pred(SplayNode* t); + SplayNode* succ(SplayNode* t); + void _kill(SplayNode* t); + SplayNode* _copy(SplayNode* t); + +public: + SplayMap( dflt); + SplayMap(SplayMap& a); + ~SplayMap(); + + & operator [] ( key); + + void del( key); + + Pix first(); + void next(Pix& i); + & key(Pix i); + & contents(Pix i); + + Pix seek( key); + int contains( key); + + void clear(); + + Pix last(); + void prev(Pix& i); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline SplayMap::~SplayMap() +{ + _kill(root); +} + +inline SplayMap::SplayMap( dflt) :(dflt) +{ + root = 0; +} + +inline SplayMap::SplayMap(SplayMap& b) :(b.def) +{ + count = b.count; + root = _copy(b.root); +} + +inline Pix SplayMap::first() +{ + return Pix(leftmost()); +} + +inline Pix SplayMap::last() +{ + return Pix(rightmost()); +} + +inline void SplayMap::next(Pix& i) +{ + if (i != 0) i = Pix(succ((SplayNode*)i)); +} + +inline void SplayMap::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((SplayNode*)i)); +} + +inline & SplayMap::key (Pix i) +{ + if (i == 0) error("null Pix"); + return ((SplayNode*)i)->item; +} + +inline & SplayMap::contents (Pix i) +{ + if (i == 0) error("null Pix"); + return ((SplayNode*)i)->cont; +} + +inline void SplayMap::clear() +{ + _kill(root); + count = 0; + root = 0; +} + +inline int SplayMap::contains( key) +{ + return seek(key) != 0; +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/SplayPQ.hP b/usr/src/lib/libg++/g++-include/gen/SplayPQ.hP new file mode 100644 index 0000000000..8c738256c4 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/SplayPQ.hP @@ -0,0 +1,157 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _SplayPQ_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _SplayPQ_h 1 + +#include ".PQ.h" + +#ifndef _SplayNode +#define _SplayNode 1 + +struct SplayNode +{ + SplayNode* lt; + SplayNode* rt; + SplayNode* par; + item; + SplayNode( h, SplayNode* l=0, SplayNode* r=0); + ~SplayNode(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline SplayNode::SplayNode( h, SplayNode* l, SplayNode* r) +:item(h), lt(l), rt(r), par(0) {} + +inline SplayNode::~SplayNode() {} + +#endif + +typedef SplayNode* SplayNodePtr; + +#endif + +class SplayPQ : public PQ +{ +protected: + SplayNode* root; + + SplayNode* leftmost(); + SplayNode* rightmost(); + SplayNode* pred(SplayNode* t); + SplayNode* succ(SplayNode* t); + void _kill(SplayNode* t); + SplayNode* _copy(SplayNode* t); + +public: + SplayPQ(); + SplayPQ(SplayPQ& a); + ~SplayPQ(); + + Pix enq( item); + deq(); + + & front(); + void del_front(); + + int contains( item); + + void clear(); + + Pix first(); + Pix last(); + void next(Pix& i); + void prev(Pix& i); + & operator () (Pix i); + void del(Pix i); + Pix seek( item); + + int OK(); // rep invariant +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline SplayPQ::~SplayPQ() +{ + _kill(root); +} + +inline SplayPQ::SplayPQ() +{ + root = 0; + count = 0; +} + +inline SplayPQ::SplayPQ(SplayPQ& b) +{ + count = b.count; + root = _copy(b.root); +} + +inline Pix SplayPQ::first() +{ + return Pix(leftmost()); +} + +inline Pix SplayPQ::last() +{ + return Pix(rightmost()); +} + +inline void SplayPQ::next(Pix& i) +{ + if (i != 0) i = Pix(succ((SplayNode*)i)); +} + +inline void SplayPQ::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((SplayNode*)i)); +} + +inline & SplayPQ::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return ((SplayNode*)i)->item; +} + +inline void SplayPQ::clear() +{ + _kill(root); + count = 0; + root = 0; +} + +inline int SplayPQ::contains( key) +{ + return seek(key) != 0; +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/SplaySet.hP b/usr/src/lib/libg++/g++-include/gen/SplaySet.hP new file mode 100644 index 0000000000..b499fdc45e --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/SplaySet.hP @@ -0,0 +1,167 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _SplaySet_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _SplaySet_h 1 + +#include ".Set.h" + +#ifndef _SplayNode +#define _SplayNode 1 + +struct SplayNode +{ + SplayNode* lt; + SplayNode* rt; + SplayNode* par; + item; + SplayNode( h, SplayNode* l=0, SplayNode* r=0); + ~SplayNode(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline SplayNode::SplayNode( h, SplayNode* l, SplayNode* r) +:item(h), lt(l), rt(r), par(0) {} + +inline SplayNode::~SplayNode() {} + +#endif + +typedef SplayNode* SplayNodePtr; + +#endif + +class SplaySet : public Set +{ +protected: + SplayNode* root; + + SplayNode* leftmost(); + SplayNode* rightmost(); + SplayNode* pred(SplayNode* t); + SplayNode* succ(SplayNode* t); + void _kill(SplayNode* t); + SplayNode* _copy(SplayNode* t); + +public: + SplaySet(); + SplaySet(SplaySet& a); + ~SplaySet(); + + Pix add( item); + void del( item); + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + Pix seek( item); + + Pix last(); + void prev(Pix& i); + + void operator |= (SplaySet& b); + void operator -= (SplaySet& b); + void operator &= (SplaySet& b); + + int operator == (SplaySet& b); + int operator != (SplaySet& b); + int operator <= (SplaySet& b); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline SplaySet::~SplaySet() +{ + _kill(root); +} + +inline SplaySet::SplaySet() +{ + root = 0; + count = 0; +} + +inline SplaySet::SplaySet(SplaySet& b) +{ + count = b.count; + root = _copy(b.root); +} + + +inline int SplaySet::operator != (SplaySet& b) +{ + return ! (*this == b); +} + +inline Pix SplaySet::first() +{ + return Pix(leftmost()); +} + +inline Pix SplaySet::last() +{ + return Pix(rightmost()); +} + +inline void SplaySet::next(Pix& i) +{ + if (i != 0) i = Pix(succ((SplayNode*)i)); +} + +inline void SplaySet::prev(Pix& i) +{ + if (i != 0) i = Pix(pred((SplayNode*)i)); +} + +inline & SplaySet::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return ((SplayNode*)i)->item; +} + +inline void SplaySet::clear() +{ + _kill(root); + count = 0; + root = 0; +} + +inline int SplaySet::contains( key) +{ + return seek(key) != 0; +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/Stack.hP b/usr/src/lib/libg++/g++-include/gen/Stack.hP new file mode 100644 index 0000000000..46c4799f45 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/Stack.hP @@ -0,0 +1,62 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _Stack_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _Stack_h + +#include + +#include ".defs.h" + +class Stack +{ +public: + Stack(); + virtual ~Stack(); + + virtual void push( item) = 0; + virtual pop() = 0; + virtual & top() = 0; + virtual void del_top() = 0; + + virtual int empty() = 0; + virtual int full() = 0; + virtual int length() = 0; + + virtual void clear() = 0; + + void error(const char*); + virtual int OK() = 0; +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) +inline Stack::Stack() {} +#endif + + +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/VHBag.hP b/usr/src/lib/libg++/g++-include/gen/VHBag.hP new file mode 100644 index 0000000000..b88673c9f0 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/VHBag.hP @@ -0,0 +1,92 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _VHBag_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _VHBag_h 1 + +#include ".Bag.h" + + +class VHBag : public Bag +{ +protected: + * tab; + char* status; + unsigned int size; + +public: + VHBag(unsigned int sz = DEFAULT_INITIAL_CAPACITY); + VHBag(VHBag& a); + ~VHBag(); + + Pix add( item); + void del( item); + void remove(item); + int nof( item); + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + Pix seek( item, Pix from = 0); + + int capacity(); + void resize(unsigned int newsize = 0); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline VHBag::~VHBag() +{ + delete [size] tab; + delete status; +} + + +inline int VHBag::capacity() +{ + return size; +} + +inline int VHBag::contains( key) +{ + return seek(key) != 0; +} + +inline & VHBag::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return *((*)i); +} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/VHMap.hP b/usr/src/lib/libg++/g++-include/gen/VHMap.hP new file mode 100644 index 0000000000..b0b1ecc08a --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/VHMap.hP @@ -0,0 +1,94 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _VHMap_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _VHMap_h 1 + +#include "..Map.h" + + +class VHMap : public Map +{ +protected: + * tab; + * cont; + char* status; + unsigned int size; + +public: + VHMap( dflt,unsigned int sz=DEFAULT_INITIAL_CAPACITY); + VHMap(VHMap& a); + ~VHMap(); + + & operator [] ( key); + + void del( key); + + Pix first(); + void next(Pix& i); + & key(Pix i); + & contents(Pix i); + + Pix seek( key); + int contains( key); + + void clear(); + void resize(unsigned int newsize = 0); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline VHMap::~VHMap() +{ + delete [size] tab; + delete [size] cont; + delete [size] status; +} + +inline int VHMap::contains( key) +{ + return seek(key) != 0; +} + +inline & VHMap::key(Pix i) +{ + if (i == 0) error("null Pix"); + return *((*)i); +} + +inline & VHMap::contents(Pix i) +{ + if (i == 0) error("null Pix"); + return cont[((unsigned)(i) - (unsigned)(tab)) / sizeof()]; +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/VHSet.hP b/usr/src/lib/libg++/g++-include/gen/VHSet.hP new file mode 100644 index 0000000000..3ec4d5253f --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/VHSet.hP @@ -0,0 +1,105 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _VHSet_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _VHSet_h 1 + +#include ".Set.h" + + + +class VHSet : public Set +{ +protected: + * tab; + char* status; + unsigned int size; + +public: + VHSet(unsigned int sz = DEFAULT_INITIAL_CAPACITY); + VHSet(VHSet& a); + ~VHSet(); + + Pix add( item); + void del( item); + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + Pix seek( item); + + void operator |= (VHSet& b); + void operator -= (VHSet& b); + void operator &= (VHSet& b); + + int operator == (VHSet& b); + int operator != (VHSet& b); + int operator <= (VHSet& b); + + int capacity(); + void resize(unsigned int newsize = 0); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline VHSet::~VHSet() +{ + delete [size] tab; + delete status; +} + + +inline int VHSet::capacity() +{ + return size; +} + +inline int VHSet::contains( key) +{ + return seek(key) != 0; +} + +inline & VHSet::operator () (Pix i) +{ + if (i == 0) error("null Pix"); + return *((*)i); +} + +inline int VHSet::operator != (VHSet& b) +{ + return ! ((*this) == b); +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/VOHSet.hP b/usr/src/lib/libg++/g++-include/gen/VOHSet.hP new file mode 100644 index 0000000000..6c71288044 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/VOHSet.hP @@ -0,0 +1,97 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Doug Schmidt + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _VOHSet_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _VOHSet_h 1 + +#include ".Set.h" + + + +class VOHSet : public Set +{ + * tab; + char* status; + int size; + int cnt; // keeps track of VALIDCELLs and DELETEDCELLs + +public: + VOHSet(int sz = DEFAULT_INITIAL_CAPACITY); + VOHSet(VOHSet&); + ~VOHSet(); + + Pix add( item); + void del( item); + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + Pix seek( item); + + void operator |= (VOHSet& b); + void operator -= (VOHSet& b); + void operator &= (VOHSet& b); + + int operator == (VOHSet& b); + int operator != (VOHSet& b); + int operator <= (VOHSet& b); + + int capacity(); + void resize(int newsize = 0); + + int OK(); +}; + + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline VOHSet::~VOHSet() +{ + delete [size] tab; + delete status; +} + + +inline int VOHSet::contains(int key) +{ + return seek(key) != 0; +} + + +inline & VOHSet::operator () (Pix p) +{ + if (p == 0) error("null Pix"); + return *((*)p); +} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/VQueue.hP b/usr/src/lib/libg++/g++-include/gen/VQueue.hP new file mode 100644 index 0000000000..66f58d84e0 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/VQueue.hP @@ -0,0 +1,139 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _VQueue_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _VQueue_h 1 + +#include ".Queue.h" + +class VQueue : public Queue +{ +protected: + int size; + int cnt; + int inp; + int outp; + * s; + +public: + + VQueue(int sz = DEFAULT_INITIAL_CAPACITY); + VQueue(VQueue&); + ~VQueue(); + + void operator = (VQueue&); + + void enq( item); + deq(); + & front(); + void del_front(); + + int length(); + int empty(); + int full(); + + int capacity(); + void resize(int sz); + void clear(); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline VQueue::VQueue(int sz) +{ + s = new [size = sz]; + cnt = inp = outp = 0; +} + +inline VQueue::~VQueue() +{ + delete [size] s; +} + +inline void VQueue::clear() +{ + inp = outp = 0; + cnt = 0; +} + +inline int VQueue::empty() +{ + return cnt <= 0; +} + +inline int VQueue::capacity() +{ + return size; +} + +inline int VQueue::full() +{ + return cnt >= size; +} + +inline int VQueue::length() +{ + return cnt; +} + +inline void VQueue::enq( item) +{ + if (cnt >= size) error("enq to full Queue."); + ++cnt; + s[inp] = item; + if (++inp == size) inp = 0; +} + +inline VQueue::deq() +{ + if (cnt <= 0) error("deq from empty Queue."); + --cnt; + int i = outp; + if (++outp == size) outp = 0; + return s[i]; +} + + +inline void VQueue::del_front() +{ + if (cnt <= 0) error("delete from empty Queue."); + --cnt; + if (++outp == size) outp = 0; +} + +inline & VQueue::front() +{ + if (empty()) error("top from empty Queue."); + return s[outp]; +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/VStack.hP b/usr/src/lib/libg++/g++-include/gen/VStack.hP new file mode 100644 index 0000000000..c41bcba921 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/VStack.hP @@ -0,0 +1,128 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _VStack_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _VStack_h 1 + +#include ".Stack.h" + +class VStack : public Stack +{ +protected: + int size; + int ptr; + * s; + +public: + + VStack(int sz = DEFAULT_INITIAL_CAPACITY); + VStack(VStack&); + ~VStack(); + + void operator = (VStack&); + void push( item); + pop(); + & top(); + void del_top(); + + int length(); + int empty(); + int full(); + void clear(); + + void resize(int sz); + int capacity(); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline VStack::VStack(int sz) +{ + s = new [size = sz]; + ptr = 0; +} + +inline VStack::~VStack() +{ + delete [size] s; +} + +inline void VStack::clear() +{ + ptr = 0; +} + +inline int VStack::capacity() +{ + return size; +} + +inline int VStack::empty() +{ + return ptr == 0; +} + +inline int VStack::full() +{ + return ptr == size; +} + +inline int VStack::length() +{ + return ptr; +} + +inline void VStack::push( item) +{ + if (full()) error("push to full stack."); + s[ptr++] = item; +} + +inline VStack::pop() +{ + if (empty()) error("pop from empty stack."); + return s[--ptr]; +} + + +inline void VStack::del_top() +{ + if (empty()) error("del_top from empty stack."); + --ptr; +} + +inline & VStack::top() +{ + if (empty()) error("top from empty stack."); + return s[ptr-1]; +} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/Vec.hP b/usr/src/lib/libg++/g++-include/gen/Vec.hP new file mode 100644 index 0000000000..8addfd6c19 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/Vec.hP @@ -0,0 +1,142 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _Vec_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _Vec_h 1 + +#ifndef __typedefs +#define __typedefs 1 +typedef void (*Procedure)(); +typedef (*Mapper)(); +typedef (*Combiner)(, ); +typedef int (*Predicate)(); +typedef int (*Comparator)(, ); +#endif + + +class Vec +{ +protected: + int len; + *s; + + Vec(int l, * d); +public: + Vec (); + Vec (int l); + Vec (int l, fill_value); + Vec (Vec&); + ~Vec (); + + Vec & operator = (Vec & a); + Vec at(int from = 0, int n = -1); + + int capacity(); + void resize(int newlen); + + & operator [] (int n); + & elem(int n); + + friend Vec concat(Vec & a, Vec & b); + friend Vec map(Mapper f, Vec & a); + friend Vec merge(Vec & a, Vec & b, Comparator f); + friend Vec combine(Combiner f, Vec & a, Vec & b); + friend Vec reverse(Vec & a); + + void reverse(); + void sort(Comparator f); + void fill( val, int from = 0, int n = -1); + + void apply(Procedure f); + reduce(Combiner f, base); + int index( targ); + + friend int operator == (Vec& a, Vec& b); + friend int operator != (Vec& a, Vec& b); + + void error(const char* msg); + void range_error(); +}; + +extern void default_Vec_error_handler(const char*); +extern one_arg_error_handler_t Vec_error_handler; + +extern one_arg_error_handler_t + set_Vec_error_handler(one_arg_error_handler_t f); + + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline Vec::Vec() +{ + len = 0; s = 0; +} + +inline Vec::Vec(int l) +{ + s = new [len = l]; +} + + +inline Vec::Vec(int l, * d) :len(l), s(d) {} + + +inline Vec::~Vec() +{ + delete[len] s; +} + + +inline & Vec::operator [] (int n) +{ + if ((unsigned)n >= len) + range_error(); + return s[n]; +} + +inline & Vec::elem(int n) +{ + return s[n]; +} + + +inline int Vec::capacity() +{ + return len; +} + + + +inline int operator != (Vec& a, Vec& b) +{ + return !(a == b); +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/XPBag.hP b/usr/src/lib/libg++/g++-include/gen/XPBag.hP new file mode 100644 index 0000000000..4e8aad719f --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/XPBag.hP @@ -0,0 +1,105 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _XPBag_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _XPBag_h 1 + +#include ".Bag.h" +#include ".XPlex.h" + +class XPBag : public Bag +{ +protected: + XPlex p; + +public: + XPBag(int chunksize = DEFAULT_INITIAL_CAPACITY); + XPBag(const XPBag&); + + Pix add( item); + void del( item); + void remove(item); + int nof( item); + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + int owns(Pix i); + Pix seek( item, Pix from = 0); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline XPBag::XPBag(int chunksize) + : p(chunksize) { count = 0; } + +inline XPBag::XPBag(const XPBag& s) : p(s.p) { count = s.count; } + +inline Pix XPBag::first() +{ + return p.first(); +} + +inline void XPBag::next(Pix & idx) +{ + p.next(idx); +} + +inline & XPBag::operator ()(Pix idx) +{ + return p(idx); +} + +inline void XPBag::clear() +{ + count = 0; p.clear(); +} + +inline int XPBag::owns (Pix idx) +{ + return p.owns(idx); +} + +inline Pix XPBag::add( item) +{ + ++count; + return p.index_to_Pix(p.add_high(item)); +} + +inline int XPBag::contains( item) +{ + return seek(item) != 0; +} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/XPDeque.hP b/usr/src/lib/libg++/g++-include/gen/XPDeque.hP new file mode 100644 index 0000000000..528766a8ce --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/XPDeque.hP @@ -0,0 +1,142 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _XPDeque_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _XPDeque_h + +#include ".XPlex.h" +#include ".Deque.h" + +class XPDeque : public Deque +{ + XPlex p; + +public: + XPDeque(int chunksize = DEFAULT_INITIAL_CAPACITY); + XPDeque(const XPDeque& d); + ~XPDeque(); + + void operator = (const XPDeque&); + + void push( item); // insert at front + void enq( item); // insert at rear + + & front(); + & rear(); + + deq(); + void del_front(); + void del_rear(); + + void clear(); + int empty(); + int full(); + int length(); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline XPDeque::XPDeque(int chunksize) + : p(chunksize) {} +inline XPDeque::XPDeque(const XPDeque& d) : p(d.p) {} + +inline XPDeque::~XPDeque() {} + +inline void XPDeque::push(item) +{ + p.add_low(item); +} + +inline void XPDeque::enq(item) +{ + p.add_high(item); +} + +inline XPDeque::deq() +{ + res = p.low_element(); + p.del_low(); + return res; +} + +inline & XPDeque::front() +{ + return p.low_element(); +} + +inline & XPDeque::rear() +{ + return p.high_element(); +} + +inline void XPDeque::del_front() +{ + p.del_low(); +} + +inline void XPDeque::del_rear() +{ + p.del_high(); +} + +inline void XPDeque::operator =(const XPDeque& s) +{ + p.operator = (s.p); +} + + +inline int XPDeque::empty() +{ + return p.empty(); +} + +inline int XPDeque::full() +{ + return p.full(); +} + +inline int XPDeque::length() +{ + return p.length(); +} + +inline int XPDeque::OK() +{ + return p.OK(); +} + +inline void XPDeque::clear() +{ + p.clear(); +} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/XPPQ.hP b/usr/src/lib/libg++/g++-include/gen/XPPQ.hP new file mode 100644 index 0000000000..46cdfdb6e8 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/XPPQ.hP @@ -0,0 +1,115 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _XPPQ_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _XPPQ_h 1 + +#include ".PQ.h" +#include ".XPlex.h" + +class XPPQ : public PQ +{ +protected: + XPlex p; + +public: + XPPQ(int chunksize = DEFAULT_INITIAL_CAPACITY); + XPPQ(const XPPQ&); + + Pix enq( item); + deq(); + + & front(); + void del_front(); + + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + void del(Pix i); + int owns(Pix i); + Pix seek( item); + + int OK(); // rep invariant +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline XPPQ::XPPQ(int chunksize) + : p(1, chunksize) { count = 0; } + +inline XPPQ::XPPQ(const XPPQ& s) : p(s.p) { count = s.count; } + +inline Pix XPPQ::first() +{ + return p.first(); +} + +inline void XPPQ::next(Pix & idx) +{ + p.next(idx); +} + +inline & XPPQ::operator ()(Pix idx) +{ + return p(idx); +} + +inline & XPPQ::front () +{ + return p.low_element(); +} + +inline XPPQ::deq () +{ + x = p.low_element(); + del_front(); + return x; +} + +inline void XPPQ::clear() +{ + count = 0; p.clear(); +} + +inline int XPPQ::contains ( item) +{ + return seek(item) != 0; +} + +inline int XPPQ::owns (Pix idx) +{ + return p.owns(idx); +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/XPQueue.hP b/usr/src/lib/libg++/g++-include/gen/XPQueue.hP new file mode 100644 index 0000000000..da070fd045 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/XPQueue.hP @@ -0,0 +1,123 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _XPQueue_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _XPQueue_h + +#include ".XPlex.h" +#include ".Queue.h" + +class XPQueue : public Queue +{ +protected: + XPlex p; + +public: + XPQueue(int chunksize = DEFAULT_INITIAL_CAPACITY); + XPQueue(const XPQueue& q); + ~XPQueue(); + + void operator = (const XPQueue&); + + void enq( item); + deq(); + & front(); + void del_front(); + + void clear(); + int empty(); + int full(); + int length(); + + int OK(); +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline XPQueue::XPQueue(int chunksize) + : p(chunksize) {} +inline XPQueue::XPQueue(const XPQueue& q) : p(q.p) {} + +inline XPQueue::~XPQueue() {} + +inline void XPQueue::enq(item) +{ + p.add_high(item); +} + +inline XPQueue::deq() +{ + res = p.low_element(); + p.del_low(); + return res; +} + +inline & XPQueue::front() +{ + return p.low_element(); +} + + +inline void XPQueue::del_front() +{ + p.del_low(); +} + +inline void XPQueue::operator =(const XPQueue& s) +{ + p.operator = (s.p); +} + +inline int XPQueue::empty() +{ + return p.empty(); +} + +inline int XPQueue::full() +{ + return p.full(); +} + +inline int XPQueue::length() +{ + return p.length(); +} + +inline int XPQueue::OK() +{ + return p.OK(); +} + +inline void XPQueue::clear() +{ + p.clear(); +} + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/XPSet.hP b/usr/src/lib/libg++/g++-include/gen/XPSet.hP new file mode 100644 index 0000000000..5e06b81d25 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/XPSet.hP @@ -0,0 +1,99 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _XPSet_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _XPSet_h 1 + +#include ".Set.h" +#include ".XPlex.h" + +class XPSet : public Set +{ +protected: + XPlex p; + +public: + XPSet(int chunksize = DEFAULT_INITIAL_CAPACITY); + XPSet(const XPSet&); + + Pix add( item); + void del( item); + int contains( item); + + void clear(); + + Pix first(); + void next(Pix& i); + & operator () (Pix i); + int owns(Pix i); + Pix seek( item); + + int OK(); +}; + + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline XPSet::XPSet(int chunksize) + : p(chunksize) { count = 0; } + +inline XPSet::XPSet(const XPSet& s) : p(s.p) { count = s.count; } + +inline Pix XPSet::first() +{ + return p.first(); +} + +inline void XPSet::next(Pix & idx) +{ + p.next(idx); +} + +inline & XPSet::operator ()(Pix idx) +{ + return p(idx); +} + +inline void XPSet::clear() +{ + count = 0; p.clear(); +} + +inline int XPSet::contains ( item) +{ + return seek(item) != 0; +} + +inline int XPSet::owns (Pix idx) +{ + return p.owns(idx); +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/XPStack.hP b/usr/src/lib/libg++/g++-include/gen/XPStack.hP new file mode 100644 index 0000000000..f0c18491e0 --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/XPStack.hP @@ -0,0 +1,124 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + + +#ifndef _XPStack_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _XPStack_h + +#include ".XPlex.h" +#include ".Stack.h" + +class XPStack : public Stack +{ + XPlex p; + +public: + XPStack(int chunksize = DEFAULT_INITIAL_CAPACITY); + XPStack(const XPStack& s); + ~XPStack(); + + void operator = (const XPStack&); + + void push( item); + pop(); + & top(); + void del_top(); + + int empty(); + int full(); + int length(); + + void clear(); + + int OK(); + +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline XPStack::XPStack(int chunksize) + : p(chunksize) {} +inline XPStack::XPStack(const XPStack& s) : p(s.p) {} + +inline XPStack::~XPStack() {} + +inline void XPStack::push(item) +{ + p.add_high(item); +} + +inline XPStack::pop() +{ + res = p.high_element(); + p.del_high(); + return res; +} + +inline & XPStack::top() +{ + return p.high_element(); +} + +inline void XPStack::del_top() +{ + p.del_high(); +} + +inline void XPStack::operator =(const XPStack& s) +{ + p.operator = (s.p); +} + +inline int XPStack::empty() +{ + return p.empty(); +} + +inline int XPStack::full() +{ + return p.full(); +} + +inline int XPStack::length() +{ + return p.length(); +} + +inline int XPStack::OK() +{ + return p.OK(); +} + +inline void XPStack::clear() +{ + p.clear(); +} + + +#endif +#endif diff --git a/usr/src/lib/libg++/g++-include/gen/XPlex.hP b/usr/src/lib/libg++/g++-include/gen/XPlex.hP new file mode 100644 index 0000000000..41acef7fff --- /dev/null +++ b/usr/src/lib/libg++/g++-include/gen/XPlex.hP @@ -0,0 +1,248 @@ +// This may look like C code, but it is really -*- C++ -*- +/* +Copyright (C) 1988 Free Software Foundation + written by Doug Lea (dl@rocky.oswego.edu) + based on code by Marc Shapiro (shapiro@sor.inria.fr) + +This file is part of GNU CC. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY. No author or distributor +accepts responsibility to anyone for the consequences of using it +or for whether it serves any particular purpose or works at all, +unless he says so in writing. Refer to the GNU CC General Public +License for full details. + +Everyone is granted permission to copy, modify and redistribute +GNU CC, but only under the conditions described in the +GNU CC General Public License. A copy of this license is +supposed to have been given to you along with GNU CC so you +can know your rights and responsibilities. It should be in a +file named COPYING. Among other things, the copyright notice +and this notice must be preserved on all copies. +*/ + +#ifndef _XPlex_h +#ifdef __GNUG__ +#pragma once +#pragma interface +#endif +#define _XPlex_h 1 + +#include ".Plex.h" + +class XPlex: public Plex +{ + IChunk* ch; // cached chunk + + void make_initial_chunks(int up = 1); + + void cache(int idx) const; + void cache(const * p) const; + + * dopred(const * p) const; + * dosucc(const * p) const; + + void set_cache(const IChunk* t) const; // logically, + // not physically const +public: + XPlex(); // set low = 0; + // fence = 0; + // csize = default + + XPlex(int ch_size); // low = 0; + // fence = 0; + // csize = ch_size + + XPlex(int lo, // low = lo; + int ch_size); // fence=lo + // csize = ch_size + + XPlex(int lo, // low = lo + int hi, // fence = hi+1 + const initval,// fill with initval, + int ch_size = 0); // csize= ch_size + // or fence-lo if 0 + + XPlex(const XPlex&); + + void operator= (const XPlex&); + +// virtuals + + + & high_element (); + & low_element (); + + const & high_element () const; + const & low_element () const; + + Pix first() const; + Pix last() const; + void prev(Pix& ptr) const; + void next(Pix& ptr) const; + int owns(Pix p) const; + & operator () (Pix p); + const & operator () (Pix p) const; + + int low() const; + int high() const; + int valid(int idx) const; + void prev(int& idx) const; + void next(int& x) const; + & operator [] (int index); + const & operator [] (int index) const; + + int Pix_to_index(Pix p) const; + Pix index_to_Pix(int idx) const; + + int can_add_high() const; + int can_add_low() const; + int full() const; + + int add_high(const elem); + int del_high (); + int add_low (const elem); + int del_low (); + + void fill(const x); + void fill(const x, int from, int to); + void clear(); + void reverse(); + void append(const XPlex& a); + void prepend(const XPlex& a); + + int OK () const; + +}; + +#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES) + +inline void XPlex::prev(int& idx) const +{ + --idx; +} + +inline void XPlex::next(int& idx) const +{ + ++idx; +} + +inline int XPlex::full () const +{ + return 0; +} + +inline int XPlex::can_add_high() const +{ + return 1; +} + +inline int XPlex::can_add_low() const +{ + return 1; +} + +inline int XPlex::valid (int idx) const +{ + return idx >= lo && idx < fnc; +} + +inline int XPlex::low() const +{ + return lo; +} + +inline int XPlex::high() const +{ + return fnc - 1; +} + +inline & XPlex:: operator [] (int idx) +{ + if (!ch->actual_index(idx)) cache(idx); + return *(ch->pointer_to(idx)); +} + +inline const & XPlex:: operator [] (int idx) const +{ + if (!ch->actual_index(idx)) cache(idx); + return *((const *)(ch->pointer_to(idx))); +} + +inline & XPlex::low_element () +{ + if (empty()) index_error(); + return *(hd->pointer_to(lo)); +} + +inline const & XPlex::low_element () const +{ + if (empty()) index_error(); + return *((const *)(hd->pointer_to(lo))); +} + +inline & XPlex::high_element () +{ + if (empty()) index_error(); + return *(tl()->pointer_to(fnc - 1)); +} + +inline const & XPlex::high_element () const +{ + if (empty()) index_error(); + return *((const *)(tl()->pointer_to(fnc - 1))); +} + +inline int XPlex::Pix_to_index(Pix px) const +{ + * p = (*)px; + if (!ch->actual_pointer(p)) cache(p); + return ch->index_of(p); +} + +inline Pix XPlex::index_to_Pix(int idx) const +{ + if (!ch->actual_index(idx)) cache(idx); + return (Pix)(ch->pointer_to(idx)); +} + +inline Pix XPlex::first() const +{ + return Pix(hd->IChunk::first_pointer()); +} + +inline Pix XPlex::last() const +{ + return Pix(tl()->IChunk::last_pointer()); +} + +inline void XPlex::prev(Pix& p) const +{ + Pix q = Pix(ch->IChunk::pred((*) p)); + p = (q == 0)? Pix(dopred((const *) p)) : q; +} + +inline void XPlex::next(Pix& p) const +{ + Pix q = Pix(ch->IChunk::succ((*) p)); + p = (q == 0)? Pix(dosucc((const *)p)) : q; +} + +inline & XPlex:: operator () (Pix p) +{ + return *((*)p); +} + +inline const & XPlex:: operator () (Pix p) const +{ + return *((const *)p); +} + +inline void XPlex::set_cache(const IChunk* t) const +{ + ((XPlex*)(this))->ch = (IChunk*)t; +} + +#endif +#endif -- 2.20.1