0707070044320242121006440003320000620000010000000460601736100000500000000002Size2 0707070044320242601006440003320000620000010000000461174122100000600000000076FilesSize Files Install Name Remove compress g++-inc.cpio libg++.a 0707070044320243351007550003320000620000010000000461174116700001000000002311Install # verify that we have someplace to put these things... if [ ! -d /usr/local ] then echo "Building the /usr/local directory...\c" mkdir /usr/local chmod 755 /usr/local chown bin /usr/local chgrp bin /usr/local echo "done." fi if [ ! -d /usr/local/bin ] then echo "Building the /usr/local/bin directory...\c" mkdir /usr/local/bin chmod 755 /usr/local/bin chown bin /usr/local/bin chgrp bin /usr/local/bin echo "done." fi if [ ! -d /usr/local/lib ] then echo "Building the /usr/local/lib directory...\c" mkdir /usr/local/lib chmod 755 /usr/local/lib chown bin /usr/local/lib chgrp bin /usr/local/lib echo "done." fi # Now move the executables to where they belong... echo "Putting the executable where it belongs...\c" # move executable mv libg++.a /usr/lib ln /usr/lib/libg++.a /usr/local/lib cat g++-inc.cpio|(cd /usr/local/lib; cpio -idBmc) echo "done." # Now make sure everything has the right permissions... echo "Setting permissions on the executable, and support files...\c" # set permissions on the files chown bin /usr/lib/libg++.a chgrp bin /usr/lib/libg++.a chmod 666 /usr/lib/libg++.a echo "done." # and finally notify the user that the things have been installed echo "Installation complete." 0707070044320244121006440003320000620000010000000460601735300000500000000016Namelibg++ 1.37.0 0707070044320245071007550003320000620000010000000460601677300000700000000350Remove # The remove process is very simple... it just removes the files created # by the install process, and updates the UA files. #remove installed files rm -f /usr/local/lib/libg++.a /usr/lib/libg++.a rm -rf /usr/local/lib/g++-include 0707070044320245171007550003320000620000010000000460601567600001100000017514compressR!1 LQ .text .data L@.bss L LQ.libU U /<U N1X OQ./HJf/H#0NX/N1x0<N@NV. /<0N1XON^NuNVdH$.B.p/N1nXO @#Ug$.8p/N1nXO.Vp /N1nXO .N1B-@-@ @Bp/. n /N(XO @-HgR` n -P. /.N1XOJfp# t` n rӐ PJg n PHH @cgn @Cg @Fg @Vg @bf& n rӐ PJf4gpѮ n Jf". /<0N1XONp.N1x n .N1V# @`$. /.N1XOJfp# t# XSX Jo n P -g& nX"n nB`Nv`B ``p# X` @dg" @fg( @ng2 @qg8 @vf>B \`p# t`p-@# p`p# T`p# \` n PHH./<  /<0N1PONp.N1x`bp @o# @p @l# @p"9 @# D nJg-H nJgB PJ tg. !/N1 XO"n"QAHhN1XOJg. n.HnN1XO. $HnN1XO nC .0/< ' n/N1XPO @ gJ TfS0m y0R0@H` .0N1r9 /<0N1PON^NuNq Based on compress.c,v 4.0 85/07/30 12:50:00 joe Release '?@(#)compress.c 1.12 10/29/86Usage: compress [-dfvcV] [-b maxbits] [file ...] uncompresszcatMissing maxbits Unknown flag: '%c'; .Z.Zr%s: not in compressed format %s: compressed with %d bits, can only handle %d bits .Z%s: already has .Z suffix -- no change r%s: filename too long to tack on .Z .Z%s already exists; do you wish to overwrite %s (y or n)? stderr not overwritten w%s: stdin: not in compressed format stdin: compressed with %d bits, can only handle %d bits Compression: %s: -- not a regular file: unchanged%s: -- has %d other links: unchanged -- file unchanged -- replaced with %suncompress: corrupt input %d.%02d%%%s Options: BITS = %d 0707070044320246751006440003320000620000010000000460601630300001500002710000g++-inc.cpio0707070000020137750407550000020000020000031242060460565037400001400000000000g++-include0707070000020032660407550000020000020000020210000460565032500002000000000000g++-include/sys0707070000020014211004440000020000020000011373070460565030100003100000000712g++-include/sys/socket.h #ifndef socket_h #pragma once #include extern "C" { #define KERNEL #include "//usr/include/sys/socket.h" #undef KERNEL #ifndef socket_h #define socket_h 1 #endif // void* in select, since different systems use int* or fd_set* int select(int, void*, void*, void*, struct timeval*); int connect(int, struct sockaddr*, int); int accept(int, struct sockaddr*, int*); int getsockname(int, struct sockaddr*, int*); } #endif 0707070000020015571004440000020000020000011435110460565030300003300000000513g++-include/sys/resource.h#ifndef resource_h #pragma once #include extern "C" { #define KERNEL #include "//usr/include/sys/resource.h" #undef KERNEL #ifndef resource_h #define resource_h 1 #endif int getrusage(int, struct rusage*); int getrlimit (int resource, struct rlimit *rlp); int setrlimit (int resource, struct rlimit *rlp); } #endif 0707070000020016541004440000020000020000010107150460565030500002700000000447g++-include/sys/wait.h#ifndef wait_h #include #define wait WaitStatus extern "C" { #include "//usr/include/sys/wait.h" #undef wait #ifndef wait_h #define wait_h 1 #endif extern int wait3(WaitStatus*, int options, struct rusage*); extern int wait4(int, WaitStatus*, int, struct rusage*); } #endif 0707070000020017571004440000020000020000011356200460565030700002700000001012g++-include/sys/file.h #ifndef file_h #pragma once /* Some folks need system types.h for things in file.h */ #include #include extern "C" { #define open c_proto_open #define fcntl c_proto_fcntl #ifdef ultrix #define KERNEL #endif #include "//usr/include/sys/file.h" /* try to guess whether file.h actually gave the right defs */ #if !defined(O_RDONLY) || !defined(O_CREAT) || !defined(O_EXCL) #include #endif #ifndef file_h #define file_h 1 #endif #undef KERNEL #undef open #undef fcntl } #endif 0707070000020020201004440000020000020000011103440460565031100002700000000374g++-include/sys/stat.h #ifndef stat_h #pragma once extern "C" { #include "//usr/include/sys/stat.h" #ifndef stat_h #define stat_h 1 int stat (char *path, struct stat *buf); int lstat (char *path, struct stat *buf); int fstat (int fd, struct stat *buf); #endif } #endif 0707070000020020251004440000020000020000011460510460565031300003000000000037g++-include/sys/times.h#pragma once #include 0707070000020020261004440000020000020000011471110460565031500002700000000037g++-include/sys/time.h#pragma once #include 0707070000020020331004440000020000020000010467550460565032100003000000000352g++-include/sys/types.h#ifndef types_h #pragma once extern "C" { #define size_t ____size_t #define ptrdiff_t ____ptrdiff_t #define wchar_t ____wchar_t #include "//usr/include/sys/types.h" #undef size_t #ifndef types_h #define types_h 1 #endif } #endif 0707070000020020441004440000020000020000011317000460565032200003000000000530g++-include/sys/param.h#ifndef param_h #pragma once #include extern "C" { #define KERNEL #include "//usr/include/sys/param.h" #undef KERNEL #ifndef param_h #define param_h 1 #endif /* kill commonly overloaded possible param.h macros */ #undef setbit #undef clrbit #undef isset #undef isclr #undef howmany #undef roundup #undef MIN #undef MAX } #endif 0707070000020020531004440000020000020000011234710460565032500003000000000430g++-include/sys/fcntl.h#ifndef sys_fcntl_h #pragma once extern "C" { #define KERNEL #if defined(unixpc) #include "//usr/include/fcntl.h" #else #include "//usr/include/sys/fcntl.h" #endif // defined(unixpc) #ifndef sys_fcntl_h #define sys_fcntl_h 1 #endif #undef KERNEL } #include #endif 0707070000020121721004440000020000020000011507330460564756200002200000004237g++-include/ACG.h// 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) 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 _ACG_h #define _ACG_h 1 #include #include #pragma once // // Additive number generator. This method is presented in Volume II // of The Art of Computer Programming by Knuth. I've coded the algorithm // and have added the extensions by Andres Nowatzyk of CMU to randomize // the result of algorithm M a bit by using an LCG & a spatial // permutation table. // // The version presented uses the same constants for the LCG that Andres // uses (chosen by trial & error). The spatial permutation table is // the same size (it's based on word size). This is for 32-bit words. // // The ``auxillary table'' used by the LCG table varies in size, and // is chosen to be the the smallest power of two which is larger than // twice the size of the state table. // class ACG : public RNG { unsigned long initialSeed; // used to reset generator int initialTableEntry; unsigned long *state; unsigned long *auxState; short stateSize; short auxSize; unsigned long lcgRecurr; short j; short k; protected: public: ACG(unsigned long seed = 0, int size = 55); virtual ~ACG(); // // Return a long-words word of random bits // virtual unsigned long asLong(); virtual void reset(); }; #endif 0707070000020120711004440000020000020000010233140460564756400002700000003100g++-include/Binomial.h// 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) 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 _Binomial_h #pragma once #define _Binomial_h 1 #include class Binomial: public Random { protected: int pN; double pU; public: Binomial(int n, double u, RNG *gen); int n(); int n(int xn); double u(); double u(int xu); virtual double operator()(); }; //#ifdef __OPTIMIZE__ inline Binomial::Binomial(int n, double u, RNG *gen) : (gen){ pN = n; pU = u; } inline int Binomial::n() { return pN; } inline int Binomial::n(int xn) { int tmp = pN; pN = xn; return tmp; } inline double Binomial::u() { return pU; } inline double Binomial::u(int xu) { double tmp = pU; pU = xu; return tmp; } //#endif #endif 0707070000020120701004440000020000020000010536520460564756600002500000020376g++-include/BitSet.h// 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 _BitSet_h #pragma once #define _BitSet_h 1 #include #include #define BITSETBITS BITS(short) struct BitSetRep { unsigned short len; // number of shorts in s unsigned short sz; // allocated slots unsigned short virt; // virtual 0 or 1 unsigned short s[1]; // bits start here }; extern BitSetRep* BitSetalloc(BitSetRep*, const unsigned short*, int, int, int); extern BitSetRep* BitSetcopy(BitSetRep*, const BitSetRep*); extern BitSetRep* BitSetresize(BitSetRep*, int); extern BitSetRep* BitSetop(const BitSetRep*, const BitSetRep*, BitSetRep*, char); extern BitSetRep* BitSetcmpl(const BitSetRep*, BitSetRep*); extern BitSetRep _nilBitSetRep; class BitSet; class BitSetBit { protected: BitSet* src; unsigned long pos; public: BitSetBit(BitSet* v, int p); BitSetBit(const BitSetBit& b); ~BitSetBit(); operator int(); int operator = (int b); int operator == (int b); int operator != (int b); }; class BitSet { protected: BitSetRep* rep; public: // constructors BitSet(); BitSet(const BitSet&); ~BitSet(); void operator = (const BitSet& y); // equality & subset tests friend int operator == (const BitSet& x, const BitSet& y); friend int operator != (const BitSet& x, const BitSet& y); friend int operator < (const BitSet& x, const BitSet& y); friend int operator <= (const BitSet& x, const BitSet& y); friend int operator > (const BitSet& x, const BitSet& y); friend int operator >= (const BitSet& x, const BitSet& y); // operations on self void operator |= (const BitSet& y); void operator &= (const BitSet& y); void operator -= (const BitSet& y); void operator ^= (const BitSet& y); void complement(); // individual bit manipulation void set(int pos); void set(int from, int to); void set(); // set all void clear(int pos); void clear(int from, int to); void clear(); // clear all void invert(int pos); void invert(int from, int to); int test(int pos) const; int test(int from, int to) const; BitSetBit operator [] (int i); // iterators int first(int b = 1) const; int last(int b = 1) const; int next(int pos, int b = 1) const; int previous(int pos, int b = 1) const; // status int empty() const; int virtual_bit() const; int count(int b = 1) const; // convertors & IO friend BitSet atoBitSet(const char* s, char f='0', char t='1', char star='*'); friend const char* BitSettoa(const BitSet& x, char f='0', char t='1', char star='*'); friend BitSet shorttoBitSet(unsigned short w); friend BitSet longtoBitSet(unsigned long w); friend ostream& operator << (ostream& s, const BitSet& x); // procedural versions of operators friend void and(const BitSet& x, const BitSet& y, BitSet& r); friend void or(const BitSet& x, const BitSet& y, BitSet& r); friend void xor(const BitSet& x, const BitSet& y, BitSet& r); friend void diff(const BitSet& x, const BitSet& y, BitSet& r); friend void complement(const BitSet& x, BitSet& r); // misc volatile void error(const char* msg) const; int OK() const; }; typedef BitSet BitSetTmp; /* operators declared inline below BitSet operator | (const BitSet& x, const BitSet& y); BitSet operator & (const BitSet& x, const BitSet& y); BitSet operator - (const BitSet& x, const BitSet& y); BitSet operator ^ (const BitSet& x, const BitSet& y); BitSet operator ~ (const BitSet& x); */ //#ifdef __OPTIMIZE__ inline int BitSet_index(int l) { return (unsigned)(l) / BITSETBITS; } inline int BitSet_pos(int l) { return l & (BITSETBITS - 1); } inline BitSet::BitSet() : rep(&_nilBitSetRep) {} inline BitSet::BitSet(const BitSet& x) :rep(BitSetcopy(0, x.rep)) {} inline BitSet::~BitSet() { if (rep != &_nilBitSetRep) delete rep; } inline void BitSet::operator = (const BitSet& y) { rep = BitSetcopy(rep, y.rep); } inline int operator != (const BitSet& x, const BitSet& y) { return !(x == y); } inline int operator > (const BitSet& x, const BitSet& y) { return y < x; } inline int operator >= (const BitSet& x, const BitSet& y) { return y <= x; } inline void and(const BitSet& x, const BitSet& y, BitSet& r) { r.rep = BitSetop(x.rep, y.rep, r.rep, '&'); } inline void or(const BitSet& x, const BitSet& y, BitSet& r) { r.rep = BitSetop(x.rep, y.rep, r.rep, '|'); } inline void xor(const BitSet& x, const BitSet& y, BitSet& r) { r.rep = BitSetop(x.rep, y.rep, r.rep, '^'); } inline void diff(const BitSet& x, const BitSet& y, BitSet& r) { r.rep = BitSetop(x.rep, y.rep, r.rep, '-'); } inline void complement(const BitSet& x, BitSet& r) { r.rep = BitSetcmpl(x.rep, r.rep); } inline BitSet operator & (const BitSet& x, const BitSet& y) return r { and(x, y, r); } inline BitSet operator | (const BitSet& x, const BitSet& y) return r { or(x, y, r); } inline BitSet operator ^ (const BitSet& x, const BitSet& y) return r { xor(x, y, r); } inline BitSet operator - (const BitSet& x, const BitSet& y) return r { diff(x, y, r); } inline BitSet operator ~ (const BitSet& x) return r { ::complement(x, r); } inline void BitSet::operator &= (const BitSet& y) { and(*this, y, *this); } inline void BitSet::operator |= (const BitSet& y) { or(*this, y, *this); } inline void BitSet::operator ^= (const BitSet& y) { xor(*this, y, *this); } inline void BitSet::operator -= (const BitSet& y) { diff(*this, y, *this); } inline void BitSet::complement() { ::complement(*this, *this); } inline int BitSet::virtual_bit() const { return rep->virt; } inline int BitSet::first(int b) const { return next(-1, b); } inline int BitSet::test(int p) const { if (p < 0) error("Illegal bit index"); int index = BitSet_index(p); return (index >= rep->len)? rep->virt : ((rep->s[index] & (1 << BitSet_pos(p))) != 0); } inline void BitSet::clear() { if (rep->len > 0) bzero(rep->s, rep->sz * sizeof(short)); rep->len = rep->virt = 0; } inline void BitSet::set() { rep = BitSetalloc(rep, 0, 0, 1, 0); } inline BitSetBit::BitSetBit(const BitSetBit& b) :src(b.src), pos(b.pos) {} inline BitSetBit::BitSetBit(BitSet* v, int p) { src = v; pos = p; } inline BitSetBit::~BitSetBit() {} inline BitSetBit::operator int() { return src->test(pos); } inline int BitSetBit::operator = (int b) { if (b) src->set(pos); else src->clear(pos); return b; } inline int BitSetBit::operator == (int b) { return src->test(pos) == b; } inline int BitSetBit::operator != (int b) { return src->test(pos) != b; } inline BitSetBit BitSet::operator [] (int i) { if (i < 0) error("illegal bit index"); return BitSetBit(this, i); } //#endif #endif 0707070000020120671004440000020000020000011650230460564757100003000000043112g++-include/BitString.h// 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 _BitString_h #pragma once #define _BitString_h 1 #include #include #define BITSTRBITS BITS(short) struct BitStrRep { unsigned int len; // length in bits unsigned short sz; // allocated slots unsigned short s[1]; // bits start here }; extern BitStrRep* BStr_alloc(BitStrRep*, const unsigned short*, int, int,int); extern BitStrRep* BStr_resize(BitStrRep*, int); extern BitStrRep* BStr_copy(BitStrRep*, const BitStrRep*); extern BitStrRep* cmpl(const BitStrRep*, BitStrRep*); extern BitStrRep* and(const BitStrRep*, const BitStrRep*, BitStrRep*); extern BitStrRep* or(const BitStrRep*, const BitStrRep*, BitStrRep*); extern BitStrRep* xor(const BitStrRep*, const BitStrRep*, BitStrRep*); extern BitStrRep* diff(const BitStrRep*, const BitStrRep*, BitStrRep*); extern BitStrRep* cat(const BitStrRep*, const BitStrRep*, BitStrRep*); extern BitStrRep* cat(const BitStrRep*, unsigned int, BitStrRep*); extern BitStrRep* lshift(const BitStrRep*, int, BitStrRep*); class BitString; class BitPattern; class BitStrBit { protected: BitString& src; unsigned int pos; public: BitStrBit(BitString& v, int p); BitStrBit(const BitStrBit& b); ~BitStrBit(); operator unsigned int() const; int operator = (unsigned int b); int operator == (unsigned int b) const ; int operator != (unsigned int b) const ; }; class BitSubString { friend class BitString; friend class BitPattern; protected: BitString& S; int pos; int len; BitSubString(BitString& x, int p, int l); BitSubString(const BitSubString& x); public: ~BitSubString(); void operator = (const BitString&); void operator = (const BitSubString&); int length() const; int empty() const; int OK() const; }; class BitString { friend class BitSubString; friend class BitPattern; protected: BitStrRep* rep; int search(int, int, const unsigned short*, int, int) const; int match(int, int, int, const unsigned short*,int,int) const; BitSubString _substr(int first, int l); public: // constructors BitString(); BitString(const BitString&); BitString(const BitSubString& y); ~BitString(); void operator = (unsigned int bit); void operator = (const BitString& y); void operator = (const BitSubString& y); // equality & subset tests friend int operator == (const BitString&, const BitString&); friend int operator != (const BitString&, const BitString&); friend int operator < (const BitString&, const BitString&); friend int operator <= (const BitString&, const BitString&); friend int operator > (const BitString&, const BitString&); friend int operator >= (const BitString&, const BitString&); // procedural versions of operators friend void and(const BitString&, const BitString&, BitString&); friend void or(const BitString&, const BitString&, BitString&); friend void xor(const BitString&, const BitString&, BitString&); friend void diff(const BitString&, const BitString&, BitString&); friend void cat(const BitString&, const BitString&, BitString&); friend void cat(const BitString&, unsigned int, BitString&); friend void lshift(const BitString&, int, BitString&); friend void rshift(const BitString&, int, BitString&); friend void complement(const BitString&, BitString&); friend int lcompare(const BitString&, const BitString&); // assignment-based operators // (constuctive versions decalred inline below void operator |= (const BitString&); void operator &= (const BitString&); void operator -= (const BitString&); void operator ^= (const BitString&); void operator += (const BitString&); void operator += (unsigned int b); void operator <<=(int s); void operator >>=(int s); void complement(); // individual bit manipulation void set(int pos); void set(int from, int to); void set(); void clear(int pos); void clear(int from, int to); void clear(); void invert(int pos); void invert(int from, int to); int test(int pos) const; int test(int from, int to) const; void assign(int p, unsigned int bit); // indexing BitStrBit operator [] (int pos); // iterators int first(unsigned int bit = 1) const; int last(unsigned int b = 1) const; int next(int pos, unsigned int b = 1) const; int previous(int pos, unsigned int b = 1) const; // searching & matching int index(unsigned int bit, int startpos = 0) const ; int index(const BitString&, int startpos = 0) const; int index(const BitSubString&, int startpos = 0) const; int index(const BitPattern&, int startpos = 0) const; int contains(const BitString&) const; int contains(const BitSubString&) const; int contains(const BitPattern&) const; int contains(const BitString&, int pos) const; int contains(const BitSubString&, int pos) const; int contains(const BitPattern&, int pos) const; int matches(const BitString&, int pos = 0) const; int matches(const BitSubString&, int pos = 0) const; int matches(const BitPattern&, int pos = 0) const; // BitSubString extraction BitSubString at(int pos, int len); BitSubString at(const BitString&, int startpos = 0); BitSubString at(const BitSubString&, int startpos = 0); BitSubString at(const BitPattern&, int startpos = 0); BitSubString before(int pos); BitSubString before(const BitString&, int startpos = 0); BitSubString before(const BitSubString&, int startpos = 0); BitSubString before(const BitPattern&, int startpos = 0); BitSubString after(int pos); BitSubString after(const BitString&, int startpos = 0); BitSubString after(const BitSubString&, int startpos = 0); BitSubString after(const BitPattern&, int startpos = 0); // other friends & utilities friend BitString common_prefix(const BitString&, const BitString&, int pos = 0); friend BitString common_suffix(const BitString&, const BitString&, int pos = -1); friend BitString reverse(const BitString&); void right_trim(unsigned int bit); void left_trim(unsigned int bit); // status int empty() const ; int count(unsigned int bit = 1) const; int length() const; // convertors & IO friend BitString atoBitString(const char* s, char f='0', char t='1'); friend const char* BitStringtoa(const BitString&, char f='0', char t='1'); friend BitString shorttoBitString(unsigned short); friend BitString longtoBitString(unsigned long); friend ostream& operator << (ostream& s, const BitString&); // misc volatile void error(const char* msg) const; // indirect friends friend const char* BitPatterntoa(const BitPattern& p, char f='0',char t='1',char x='X'); friend BitPattern atoBitPattern(const char* s, char f='0',char t='1',char x='X'); int OK() const; }; class BitPattern { public: BitString pattern; BitString mask; BitPattern(); BitPattern(const BitPattern&); BitPattern(const BitString& p, const BitString& m); ~BitPattern(); friend const char* BitPatterntoa(const BitPattern&, char f, char t, char x); friend BitPattern atoBitPattern(const char* s, char f,char t, char x); friend ostream& operator << (ostream& s, const BitPattern&); int search(const unsigned short*, int, int) const; int match(const unsigned short* xs, int, int, int) const; int OK() const; }; //#ifdef __OPTIMIZE__ // primitive bit extraction inline static int BitStr_index(int l) { return (unsigned)(l) / BITSTRBITS; } inline static int BitStr_pos(int l) { return l & (BITSTRBITS - 1); } extern BitStrRep _nilBitStrRep; extern BitString _nil_BitString; // constructors & assignment inline BitString::BitString() :rep(&_nilBitStrRep) {} inline BitString::BitString(const BitString& x) :rep(BStr_copy(0, x.rep)) {} inline BitString::BitString(const BitSubString& y) :rep (BStr_alloc(0, y.S.rep->s, y.pos, y.pos+y.len, y.len)) {} inline BitString::~BitString() { if (rep != &_nilBitStrRep) delete rep; } inline BitString shorttoBitString(unsigned short w) return r { r.rep = BStr_alloc(0, &w, 0, BITSTRBITS, BITSTRBITS); } inline void BitString::operator = (const BitString& y) { rep = BStr_copy(rep, y.rep); } inline void BitString::operator = (unsigned int b) { unsigned short bit = b; rep = BStr_alloc(rep, &bit, 0, 1, 1); } inline void BitString::operator=(const BitSubString& y) { rep = BStr_alloc(rep, y.S.rep->s, y.pos, y.pos+y.len, y.len); } inline BitSubString::BitSubString(const BitSubString& x) :S(x.S), pos(x.pos), len(x.len) {} inline BitSubString::BitSubString(BitString& x, int p, int l) : S(x), pos(p), len(l) {} inline BitSubString::~BitSubString() {} inline BitPattern::BitPattern(const BitString& p, const BitString& m) :pattern(p), mask(m) {} inline BitPattern::BitPattern(const BitPattern& b) :pattern(b.pattern), mask(b.mask) {} inline BitPattern::BitPattern() {} inline BitPattern::~BitPattern() {} inline BitString longtoBitString(unsigned long w) return r { unsigned short u[2]; u[0] = w & ((unsigned short)(~(0))); u[1] = w >> BITSTRBITS; r.rep = BStr_alloc(0, &u[0], 0, 2*BITSTRBITS, 2*BITSTRBITS); } // procedural versions of operators inline void and(const BitString& x, const BitString& y, BitString& r) { r.rep = and(x.rep, y.rep, r.rep); } inline void or(const BitString& x, const BitString& y, BitString& r) { r.rep = or(x.rep, y.rep, r.rep); } inline void xor(const BitString& x, const BitString& y, BitString& r) { r.rep = xor(x.rep, y.rep, r.rep); } inline void diff(const BitString& x, const BitString& y, BitString& r) { r.rep = diff(x.rep, y.rep, r.rep); } inline void cat(const BitString& x, const BitString& y, BitString& r) { r.rep = cat(x.rep, y.rep, r.rep); } inline void cat(const BitString& x, unsigned int y, BitString& r) { r.rep = cat(x.rep, y, r.rep); } inline void rshift(const BitString& x, int y, BitString& r) { r.rep = lshift(x.rep, -y, r.rep); } inline void lshift(const BitString& x, int y, BitString& r) { r.rep = lshift(x.rep, y, r.rep); } inline void complement(const BitString& x, BitString& r) { r.rep = cmpl(x.rep, r.rep); } // operators inline BitString operator & (const BitString& x, const BitString& y) return r { and(x, y, r); } inline void BitString::operator &= (const BitString& y) { and(*this, y, *this); } inline BitString operator | (const BitString& x, const BitString& y) return r { or(x, y, r); } inline void BitString::operator |= (const BitString& y) { or(*this, y, *this); } inline BitString operator ^ (const BitString& x, const BitString& y) return r { xor(x, y, r); } inline void BitString::operator ^= (const BitString& y) { xor(*this, y, *this); } inline BitString operator << (const BitString& x, int y) return r { lshift(x, y, r); } inline void BitString::operator <<= (int y) { lshift(*this, y, *this); } inline BitString operator >> (const BitString& x, int y) return r { rshift(x, y, r); } inline void BitString::operator >>= (int y) { rshift(*this, y, *this); } inline BitString operator - (const BitString& x, const BitString& y) return r { diff(x, y, r); } inline void BitString::operator -= (const BitString& y) { diff(*this, y, *this); } inline BitString operator + (const BitString& x, const BitString& y) return r { cat(x, y, r); } inline void BitString::operator += (const BitString& y) { cat(*this, y, *this); } inline BitString operator + (const BitString& x, unsigned int y) return r { cat(x, y, r); } inline void BitString::operator += (unsigned int y) { cat(*this, y, *this); } inline BitString operator ~ (const BitString& x) return r { complement(x, r); } inline void BitString::complement() { ::complement(*this, *this); } // status, matching inline int BitString::length() const { return rep->len; } inline int BitString::empty() const { return rep->len == 0; } inline int BitString::index(const BitString& y, int startpos) const { return search(startpos, rep->len, y.rep->s, 0, y.rep->len); } inline int BitString::index(const BitSubString& y, int startpos) const { return search(startpos, rep->len, y.S.rep->s, y.pos, y.pos+y.len); } inline int BitString::contains(const BitString& y) const { return search(0, rep->len, y.rep->s, 0, y.rep->len) >= 0; } inline int BitString::contains(const BitSubString& y) const { return search(0, rep->len, y.S.rep->s, y.pos, y.pos+y.len) >= 0; } inline int BitString::contains(const BitString& y, int p) const { return match(p, rep->len, 0, y.rep->s, 0, y.rep->len); } inline int BitString::matches(const BitString& y, int p) const { return match(p, rep->len, 1, y.rep->s, 0, y.rep->len); } inline int BitString::contains(const BitSubString& y, int p) const { return match(p, rep->len, 0, y.S.rep->s, y.pos, y.pos+y.len); } inline int BitString::matches(const BitSubString& y, int p) const { return match(p, rep->len, 1, y.S.rep->s, y.pos, y.pos+y.len); } inline int BitString::contains(const BitPattern& r) const { return r.search(rep->s, 0, rep->len) >= 0; } inline int BitString::contains(const BitPattern& r, int p) const { return r.match(rep->s, p, rep->len, 0); } inline int BitString::matches(const BitPattern& r, int p) const { return r.match(rep->s, p, rep->len, 1); } inline int BitString::index(const BitPattern& r, int startpos) const { return r.search(rep->s, startpos, rep->len); } inline int BitSubString::length() const { return len; } inline int BitSubString::empty() const { return len == 0; } inline int operator != (const BitString& x, const BitString& y) { return !(x == y); } inline int operator>(const BitString& x, const BitString& y) { return y < x; } inline int operator>=(const BitString& x, const BitString& y) { return y <= x; } inline int BitString::first(unsigned int b) const { return next(-1, b); } inline int BitString::last(unsigned int b) const { return previous(rep->len, b); } inline int BitString::index(unsigned int bit, int startpos) const { if (startpos >= 0) return next(startpos - 1, bit); else return previous(rep->len + startpos + 1, bit); } inline void BitString::right_trim(unsigned int b) { int nb = (b == 0)? 1 : 0; rep = BStr_resize(rep, previous(rep->len, nb) + 1); } inline void BitString::left_trim(unsigned int b) { int nb = (b == 0)? 1 : 0; int p = next(-1, nb); rep = BStr_alloc(rep, rep->s, p, rep->len, rep->len - p); } inline int BitString::test(int i) const { return ((unsigned)(i) >= rep->len)? 0 : ((rep->s[BitStr_index(i)] & (1 << (BitStr_pos(i)))) != 0); } // subscripting inline BitStrBit::BitStrBit(const BitStrBit& b) :src(b.src), pos(b.pos) {} inline BitStrBit::BitStrBit(BitString& v, int p) :src(v), pos(p) {} inline BitStrBit::~BitStrBit() {} inline BitStrBit::operator unsigned int() const { return src.test(pos); } inline int BitStrBit::operator = (unsigned int b) { src.assign(pos, b); return b; } inline int BitStrBit::operator == (unsigned int b) const { return src.test(pos) == b; } inline int BitStrBit::operator != (unsigned int b) const { return src.test(pos) != b; } inline BitStrBit BitString::operator [] (int i) { if ((unsigned)(i) >= rep->len) error("illegal bit index"); return BitStrBit(*this, i); } inline BitSubString BitString::_substr(int first, int l) { if (first < 0 || l <= 0 || (unsigned)(first + l) > rep->len) return BitSubString(_nil_BitString, 0, 0) ; else return BitSubString(*this, first, l); } //#endif #endif 0707070000020012501004440000020000020000010546550460564757300002600000014334g++-include/Complex.h// 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 _Complex_h #pragma once #define _Complex_h 1 #include #include class Complex { protected: double re; double im; public: inline double /* const */ real() const; inline double /* const */ imag() const; inline Complex(); inline Complex(const Complex& y); inline Complex(double r, double i=0); inline ~Complex(); inline Complex& operator = (const Complex& y); inline Complex& operator += (const Complex& y); inline Complex& operator += (double y); inline Complex& operator -= (const Complex& y); inline Complex& operator -= (double y); inline Complex& operator *= (const Complex& y); inline Complex& operator *= (double y); Complex& operator /= (const Complex& y); Complex& operator /= (double y); void error(const char* msg) const; }; // inline members inline double /* const */ Complex::real() const { return re; } inline double /* const */ Complex::imag() const { return im; } inline Complex::Complex() {} inline Complex::Complex(const Complex& y) :re(y.real()), im(y.imag()) {} inline Complex::Complex(double r, double i) :re(r), im(i) {} inline Complex::~Complex() {} inline Complex& Complex::operator = (const Complex& y) { re = y.real(); im = y.imag(); return *this; } inline Complex& Complex::operator += (const Complex& y) { re += y.real(); im += y.imag(); return *this; } inline Complex& Complex::operator += (double y) { re += y; return *this; } inline Complex& Complex::operator -= (const Complex& y) { re -= y.real(); im -= y.imag(); return *this; } inline Complex& Complex::operator -= (double y) { re -= y; return *this; } inline Complex& Complex::operator *= (const Complex& y) { double r = re * y.real() - im * y.imag(); im = re * y.imag() + im * y.real(); re = r; return *this; } inline Complex& Complex::operator *= (double y) { re *= y; im *= y; return *this; } // error handlers extern void default_Complex_error_handler(const char*); extern one_arg_error_handler_t Complex_error_handler; extern one_arg_error_handler_t set_Complex_error_handler(one_arg_error_handler_t f); // non-inline functions Complex /* const */ operator / (const Complex& x, const Complex& y); Complex /* const */ operator / (const Complex& x, double y); Complex /* const */ operator / (double x, const Complex& y); Complex /* const */ cos(const Complex& x); Complex /* const */ sin(const Complex& x); Complex /* const */ cosh(const Complex& x); Complex /* const */ sinh(const Complex& x); Complex /* const */ exp(const Complex& x); Complex /* const */ log(const Complex& x); Complex /* const */ pow(const Complex& x, long p); Complex /* const */ pow(const Complex& x, const Complex& p); Complex /* const */ sqrt(const Complex& x); istream& operator >> (istream& s, Complex& x); ostream& operator << (ostream& s, const Complex& x); // inline functions inline int /* const */ operator == (const Complex& x, const Complex& y) { return x.real() == y.real() && x.imag() == y.imag(); } inline int /* const */ operator == (const Complex& x, double y) { return x.imag() == 0.0 && x.real() == y; } inline int /* const */ operator != (const Complex& x, const Complex& y) { return x.real() != y.real() || x.imag() != y.imag(); } inline int /* const */ operator != (const Complex& x, double y) { return x.imag() != 0.0 || x.real() != y; } inline Complex /* const */ operator - (const Complex& x) { return Complex(-x.real(), -x.imag()); } inline Complex /* const */ conj(const Complex& x) { return Complex(x.real(), -x.imag()); } inline Complex /* const */ operator + (const Complex& x, const Complex& y) { return Complex(x.real() + y.real(), x.imag() + y.imag()); } inline Complex /* const */ operator + (const Complex& x, double y) { return Complex(x.real() + y, x.imag()); } inline Complex /* const */ operator + (double x, const Complex& y) { return Complex(x + y.real(), y.imag()); } inline Complex /* const */ operator - (const Complex& x, const Complex& y) { return Complex(x.real() - y.real(), x.imag() - y.imag()); } inline Complex /* const */ operator - (const Complex& x, double y) { return Complex(x.real() - y, x.imag()); } inline Complex /* const */ operator - (double x, const Complex& y) { return Complex(x - y.real(), -y.imag()); } inline Complex /* const */ operator * (const Complex& x, const Complex& y) { return Complex(x.real() * y.real() - x.imag() * y.imag(), x.real() * y.imag() + x.imag() * y.real()); } inline Complex /* const */ operator * (const Complex& x, double y) { return Complex(x.real() * y, x.imag() * y); } inline Complex /* const */ operator * (double x, const Complex& y) { return Complex(x * y.real(), x * y.imag()); } inline double /* const */ real(const Complex& x) { return x.real(); } inline double /* const */ imag(const Complex& x) { return x.imag(); } inline double /* const */ abs(const Complex& x) { return hypot(x.real(), x.imag()); } inline double /* const */ norm(const Complex& x) { return (x.real() * x.real() + x.imag() * x.imag()); } inline double /* const */ arg(const Complex& x) { return atan2(x.imag(), x.real()); } inline Complex /* const */ polar(double r, double t = 0.0) { return Complex(r * cos(t), r * sin(t)); } #endif 0707070000020011641004440000020000020000010275560460564757500003300000003572g++-include/DiscreteUnifor// 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) 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 _DiscreteUniform_h #pragma once #define _DiscreteUniform_h 1 #include // // The interval [lo..hi) // class DiscreteUniform: public Random { long pLow; long pHigh; double delta; public: DiscreteUniform(long low, long high, RNG *gen); long low(); long low(long x); long high(); long high(long x); virtual double operator()(); }; //#ifdef __OPTIMIZE__ inline DiscreteUniform::DiscreteUniform(long low, long high, RNG *gen) : (gen) { pLow = (low < high) ? low : high; pHigh = (low < high) ? high : low; delta = (pHigh - pLow) + 1; } inline long DiscreteUniform::low() { return pLow; } inline long DiscreteUniform::low(long x) { long tmp = pLow; pLow = x; delta = (pHigh - pLow) + 1; return tmp; } inline long DiscreteUniform::high() { return pHigh; } inline long DiscreteUniform::high(long x) { long tmp = pHigh; pHigh = x; delta = (pHigh - pLow) + 1; return tmp; } //#endif #endif 0707070000020012521004440000020000020000011111160460564757700002500000003631g++-include/Erlang.h// 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) 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 _Erlang_h #pragma once #define _Erlang_h 1 #include class Erlang: public Random { protected: double pMean; double pVariance; int k; double a; void setState(); public: Erlang(double mean, double variance, RNG *gen); double mean(); double mean(double x); double variance(); double variance(double x); virtual double operator()(); }; //#ifdef __OPTIMIZE__ inline void Erlang::setState() { k = int( (pMean * pMean ) / pVariance + 0.5 ); k = (k > 0) ? k : 1; a = k / pMean; } inline Erlang::Erlang(double mean, double variance, RNG *gen) : (gen) { pMean = mean; pVariance = variance; setState(); } inline double Erlang::mean() { return pMean; } inline double Erlang::mean(double x) { double tmp = pMean; pMean = x; setState(); return tmp; }; inline double Erlang::variance() { return pVariance; } inline double Erlang::variance(double x) { double tmp = pVariance; pVariance = x; setState(); return tmp; } //#endif #endif 0707070000020120641004440000020000020000011560520460564760100002300000017326g++-include/File.h// 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 _File_h #pragma once #define _File_h 1 #include #include #include enum io_mode // known unix file IO modes { io_readonly = 0, io_writeonly = 1, io_readwrite = 2, io_appendonly = 3, io_append = 4, // append, plus allow reads }; enum access_mode // ways to open a file { a_createonly = 0, // create, fail if file exists a_create = 1, // create if doesn't exist, else truncate a_useonly = 2, // use (no truncate) fail if doesn't exist a_use = 3, // use (no truncate), create if doesn't exist }; enum state_value // File states { _good = 0, // all is well _eof = 1, // at eof _fail = 2, // logical or physical IO error _bad = 4 // unopened/corrupted }; class Filebuf; class File { friend class Filebuf; protected: FILE* fp; // _iobuf file pointer char* nm; // file name (dynamically allocated) char rw; // 1 = read; 2 = write; 3 = readwrite // bit 2 (4) means read/write into string state_value state; // _good/_eof/_fail/_bad long stat; // last read/write/... return value void initialize(); void reinitialize(const char*); char *readline (int chunk_number, char terminator); public: File(); File(const char* filename, io_mode m, access_mode a); File(const char* filename, const char* m); File(int filedesc, io_mode m); File(FILE* fileptr); File(int sz, char* buf, io_mode m); ~File(); // binding, rebinding, unbinding to physical files File& open(const char* filename, io_mode m, access_mode a); File& open(const char* filename, const char* m); File& open(int filedesc, io_mode m); File& open(FILE* fileptr); File& close(); File& remove(); // class variable access int filedesc(); const char* name(); void setname(const char* newname); int iocount(); int rdstate(); int eof(); int fail(); int bad(); int good(); // other status queries int readable(); int writable(); int is_open(); operator void*(); // error handling void error(); void clear(state_value f = _good); // poorly named void set(state_value f); // set corresponding but void unset(state_value f); // clear corresponding bit File& failif(int cond); void check_state(); // character IO File& get(char& c); File& put(char c); File& unget(char c); File& putback(char c); // a synonym for unget // char* IO File& put(const char* s); File& get (char* s, int n, char terminator = '\n'); File& getline(char* s, int n, char terminator = '\n'); File& gets (char **s, char terminator = '\n'); // binary IO File& read(void* x, int sz, int n); File& write(void* x, int sz, int n); // formatted IO File& form(const char* ...); File& scan(const char* ...); // buffer IO File& flush(); File& flush(char ch); // call stdio _flsbuf int fill(); // call stdio _filbuf // position control File& seek(long pos, int seek_mode=0); // default seek mode=absolute long tell(); // buffer control File& setbuf(int buffer_kind); // legal vals: _IONBF, _IOFBF, _IOLBF File& setbuf(int size, char* buf); File& raw(); }; // error handlers extern void verbose_File_error_handler(const char*); extern void quiet_File_error_handler(const char*); extern void fatal_File_error_handler(const char*); extern one_arg_error_handler_t File_error_handler; extern one_arg_error_handler_t set_File_error_handler(one_arg_error_handler_t); //#ifdef __OPTIMIZE__ inline int File::filedesc() { return fileno(fp); } inline const char* File::name() { return nm; } inline int File::iocount() { return stat; } inline void File::clear(state_value flag) { state = flag; } inline void File::set(state_value flag) { state = state_value(int(state) | int(flag)); } inline void File::unset(state_value flag) { state = state_value(int(state) & ~int(flag)); } inline int File::readable() { if (fp != 0) { if (feof(fp)) set(_eof); if (ferror(fp)) set(_bad);} return (state == _good && (rw & 01)); } inline int File::writable() { if (fp != 0 && ferror(fp)) set(_bad); return ((int(state) & (int(_fail)|int(_bad))) == 0 && (rw & 02)); } inline int File::is_open() { return (fp != 0); } inline File& File::raw() { return this->File::setbuf(_IONBF); } inline File& File::failif(int cond) { if (cond) set(_fail); return *this; } inline File& File::get(char& c) { if (readable()) { int ch = getc(fp); c = ch; failif (ch == EOF); } return *this; } inline File& File::put(char c) { return failif (!writable() || putc(c, fp) == EOF); } inline File& File::unget(char c) { return failif(!is_open() || !(rw & 01) || ungetc(c, fp) == EOF); } inline File& File::putback(char c) { return failif (!is_open() || !(rw & 01) || ungetc(c, fp) == EOF); } inline File& File::read(void* x, int sz, int n) { return failif (!readable() || (stat = fread(x, sz, n, fp)) != n); } inline File& File::write(void* x, int sz, int n) { return failif (!writable() || (stat = fwrite(x, sz, n, fp)) != n); } inline File& File::flush() { return failif(!is_open() || fflush(fp) == EOF); } inline File& File::flush(char ch) { return failif(!is_open() || _flsbuf(ch, fp) == EOF); } inline int File::fill() { failif(!is_open() || (stat = _filbuf(fp)) == EOF); return stat; } inline File& File::seek(long pos, int seek_mode) { return failif (!is_open() || fseek(fp, pos, seek_mode) < 0); } inline long File::tell() { failif (!is_open() || ((stat = ftell(fp)) < 0)); return stat; } inline int File::rdstate() { check_state(); return state; // check_state is necessary in rare but } // possible circumstances inline File::operator void*() { check_state(); return (int(state) & (int(_bad)|int(_fail)))? 0 : this ; } inline int File::eof() { check_state(); return state & _eof; } inline int File::fail() { check_state(); return state & _fail; } inline int File::bad() { check_state(); return state & _bad; } inline int File::good() { check_state(); return rdstate() == _good; } //#endif #endif 0707070000020012341004440000020000020000011015140460564760300002200000022703g++-include/Fix.h// // Fix.h : variable length fixed point data type // #ifndef _Fix_h #pragma once #define _Fix_h 1 #include #include #include #include typedef unsigned short uint16; typedef short int16; typedef unsigned long uint32; typedef long int32; #define _Fix_min_length 1 #define _Fix_max_length 65535 #define _Fix_min_value -1.0 #define _Fix_max_value 1.0 extern uint16 Fix_default_length; extern int Fix_default_print_width; struct _Frep // internal Fix representation { uint16 len; // length in bits uint16 siz; // allocated storage int16 ref; // reference count uint16 s[1]; // start of ushort array represention }; typedef struct _Frep* _Fix; extern _Frep _Frep_0; extern _Frep _Frep_m1; extern _Frep _Frep_quotient_bump; class Fix { _Fix rep; Fix(_Fix); void unique(); public: Fix(); Fix(Fix&); Fix(double&); Fix(int); Fix(int, Fix&); Fix(int, double&); Fix(int, _Frep*); ~Fix(); Fix operator = (Fix&); Fix operator = (double&); friend int operator == (Fix&, Fix& ); friend int operator != (Fix&, Fix&); friend int operator < (Fix&, Fix&); friend int operator <= (Fix&, Fix&); friend int operator > (Fix&, Fix&); friend int operator >= (Fix&, Fix&); Fix& operator + (); Fix operator - (); friend Fix operator + (Fix&, Fix&); friend Fix operator - (Fix&, Fix&); friend Fix operator * (Fix&, Fix&); friend Fix operator / (Fix&, Fix&); friend Fix operator * (Fix&, int); friend Fix operator * (int, Fix&); friend Fix operator % (Fix&, int); friend Fix operator << (Fix&, int); friend Fix operator >> (Fix&, int); #ifdef __GNUG__ friend Fix operator ? (Fix&, Fix&); // max #endif Fix operator += (Fix&); Fix operator -= (Fix&); Fix operator *= (Fix&); Fix operator /= (Fix&); Fix operator *= (int); Fix operator %= (int); Fix operator <<=(int); Fix operator >>=(int); friend char* Ftoa(Fix&, int width = Fix_default_print_width); friend Fix atoF(const char*, int len = Fix_default_length); friend istream& operator >> (istream&, Fix&); friend ostream& operator << (ostream&, Fix&); // built-in functions friend Fix abs(Fix); // absolute value friend int sgn(Fix&); // -1, 0, +1 friend Integer mantissa(Fix&); // integer representation friend double value(Fix&); // double value friend int length(Fix&); // field length friend void show(Fix&); // show contents // error handlers void error(const char* msg); // error handler void range_error(const char* msg); // range error handler // internal class functions friend void mask(_Fix); friend int compare(_Fix, _Fix = &_Frep_0); friend _Fix new_Fix(uint16); friend _Fix new_Fix(uint16, _Fix); friend _Fix new_Fix(uint16, double); friend _Fix copy(_Fix, _Fix); friend _Fix negate(_Fix, _Fix = NULL); friend _Fix add(_Fix, _Fix, _Fix = NULL); friend _Fix subtract(_Fix, _Fix, _Fix = NULL); friend _Fix multiply(_Fix, _Fix, _Fix = NULL); friend _Fix multiply(_Fix, int, _Fix = NULL); friend _Fix divide(_Fix, _Fix, _Fix = NULL, _Fix = NULL); friend _Fix shift(_Fix, int, _Fix = NULL); // non-operator versions for user friend void negate(Fix& x, Fix& r); friend void add(Fix& x, Fix& y, Fix& r); friend void subtract(Fix& x, Fix& y, Fix& r); friend void multiply(Fix& x, Fix& y, Fix& r); friend void divide(Fix& x, Fix& y, Fix& q, Fix& r); friend void shift(Fix& x, int y, Fix& r); }; // error handlers extern void default_Fix_error_handler(const char*), default_Fix_range_error_handler(const char*); extern one_arg_error_handler_t Fix_error_handler, Fix_range_error_handler; extern one_arg_error_handler_t set_Fix_error_handler(one_arg_error_handler_t f), set_Fix_range_error_handler(one_arg_error_handler_t f); typedef void (*Fix_peh)(_Fix&); extern Fix_peh Fix_overflow_handler; extern void Fix_overflow_saturate(_Fix&), Fix_overflow_wrap(_Fix&), Fix_overflow_warning_saturate(_Fix&), Fix_overflow_warning(_Fix&), Fix_overflow_error(_Fix&); extern Fix_peh set_overflow_handler(Fix_peh); extern int Fix_set_default_length(int); // function definitions inline void Fix::unique() { if ( rep->ref > 1 ) { rep->ref--; rep = new_Fix(rep->len,rep); } } inline void mask (_Fix x) { int n = x->len & 0x0f; if ( n ) x->s[x->siz - 1] &= 0xffff0000 >> n; } inline _Fix copy(_Fix from, _Fix to) { uint16 *ts = to->s, *fs = from->s; int ilim = to->siz < from->siz ? to->siz : from->siz; for ( int i=0; i < ilim; i++ ) *ts++ = *fs++; for ( ; i < to->siz; i++ ) *ts++ = 0; mask(to); return to; } inline Fix::Fix(_Fix f) { rep = f; } inline Fix::Fix() { rep = new_Fix(Fix_default_length); } inline Fix::Fix(int len) { if ( len < _Fix_min_length || len > _Fix_max_length ) error("illegal length in declaration"); rep = new_Fix((uint16 )len); } inline Fix::Fix(double& d) { rep = new_Fix(Fix_default_length,d); } inline Fix::Fix(Fix& y) { rep = y.rep; rep->ref++; } inline Fix::Fix(int len, Fix& y) { if ( len < _Fix_min_length || len > _Fix_max_length ) error("illegal length in declaration"); rep = new_Fix((uint16 )len,y.rep); } inline Fix::Fix(int len, _Frep* fr) { if ( len < 1 || len > 65535 ) error("illegal length in declaration"); rep = new_Fix((uint16 )len,fr); } inline Fix::Fix(int len, double& d) { if ( len < _Fix_min_length || len > _Fix_max_length ) error("illegal length in declaration"); rep = new_Fix((uint16 )len,d); } inline Fix::~Fix() { if ( --rep->ref <= 0 ) delete rep; } inline Fix Fix::operator = (Fix& y) { if ( rep->len == y.rep->len ) { ++y.rep->ref; if ( --rep->ref <= 0 ) delete rep; rep = y.rep; } else { unique(); copy(y.rep,rep); } return *this; } inline Fix Fix::operator = (double& d) { int oldlen = rep->len; if ( --rep->ref <= 0 ) delete rep; rep = new_Fix(oldlen,d); return *this; } inline int operator == (Fix& x, Fix& y) { return compare(x.rep, y.rep) == 0; } inline int operator != (Fix& x, Fix& y) { return compare(x.rep, y.rep) != 0; } inline int operator < (Fix& x, Fix& y) { return compare(x.rep, y.rep) < 0; } inline int operator <= (Fix& x, Fix& y) { return compare(x.rep, y.rep) <= 0; } inline int operator > (Fix& x, Fix& y) { return compare(x.rep, y.rep) > 0; } inline int operator >= (Fix& x, Fix& y) { return compare(x.rep, y.rep) >= 0; } inline Fix& Fix::operator + () { return *this; } inline Fix Fix::operator - () { _Fix r = negate(rep); return r; } inline Fix operator + (Fix& x, Fix& y) { _Fix r = add(x.rep, y.rep); return r; } inline Fix operator - (Fix& x, Fix& y) { _Fix r = subtract(x.rep, y.rep); return r; } inline Fix operator * (Fix& x, Fix& y) { _Fix r = multiply(x.rep, y.rep); return r; } inline Fix operator * (Fix& x, int y) { _Fix r = multiply(x.rep, y); return r; } inline Fix operator * (int y, Fix& x) { _Fix r = multiply(x.rep, y); return r; } inline Fix operator / (Fix& x, Fix& y) { _Fix r = divide(x.rep, y.rep); return r; } inline Fix Fix::operator += (Fix& y) { unique(); add(rep, y.rep, rep); return *this; } inline Fix Fix::operator -= (Fix& y) { unique(); subtract(rep, y.rep, rep); return *this; } inline Fix Fix::operator *= (Fix& y) { unique(); multiply(rep, y.rep, rep); return *this; } inline Fix Fix::operator *= (int y) { unique(); multiply(rep, y, rep); return *this; } inline Fix Fix::operator /= (Fix& y) { unique(); divide(rep, y.rep, rep); return *this; } inline Fix operator % (Fix& x, int y) { Fix r((int )x.rep->len + y, x); return r; } inline Fix operator << (Fix& x, int y) { _Fix rep = shift(x.rep, y); return rep; } inline Fix operator >> (Fix& x, int y) { _Fix rep = shift(x.rep, -y); return rep; } inline Fix Fix::operator <<= (int y) { unique(); shift(rep, y, rep); return *this; } inline Fix Fix::operator >>= (int y) { unique(); shift(rep, -y, rep); return *this; } #ifdef __GNUG__ inline Fix operator ? (Fix& x, Fix& y) { if ( compare(x.rep, y.rep) >= 0 ) return x; else return y; } #endif inline Fix abs(Fix x) { _Fix r = (compare(x.rep) >= 0 ? new_Fix(x.rep->len,x.rep) : negate(x.rep)); return r; } inline int sgn(Fix& x) { int a = compare(x.rep); return a == 0 ? 0 : (a > 0 ? 1 : -1); } inline int length(Fix& x) { return x.rep->len; } inline ostream& operator << (ostream& s, Fix& y) { return s << Ftoa(y); } inline void negate (Fix& x, Fix& r) { negate(x.rep, r.rep); } inline void add (Fix& x, Fix& y, Fix& r) { add(x.rep, y.rep, r.rep); } inline void subtract (Fix& x, Fix& y, Fix& r) { subtract(x.rep, y.rep, r.rep); } inline void multiply (Fix& x, Fix& y, Fix& r) { multiply(x.rep, y.rep, r.rep); } inline void divide (Fix& x, Fix& y, Fix& q, Fix& r) { divide(x.rep, y.rep, q.rep, r.rep); } inline void shift (Fix& x, int y, Fix& r) { shift(x.rep, y, r.rep); } #endif 0707070000020012311004440000020000020000011602310460564760500003000000002700g++-include/Geometric.h// 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) 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 _Geometric_h #pragma once #define _Geometric_h #include class Geometric: public Random { protected: double pMean; public: Geometric(double mean, RNG *gen); double mean(); double mean(double x); virtual double operator()(); }; //#ifdef __OPTIMIZE__ inline Geometric::Geometric(double mean, RNG *gen) : (gen) { pMean = mean; } inline double Geometric::mean() { return pMean; } inline double Geometric::mean(double x) { double tmp = pMean; pMean = x; return tmp; } //#endif #endif 0707070000020010271004440000020000020000010410300460564760700003300000003750g++-include/HyperGeometric// 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) 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 _HyperGeometric_h #pragma once #define _HyperGeometric_h #include class HyperGeometric: public Random { protected: double pMean; double pVariance; double pP; void setState(); public: HyperGeometric(double mean, double variance, RNG *gen); double mean(); double mean(double x); double variance(); double variance(double x); virtual double operator()(); }; //#ifdef __OPTIMIZE__ inline void HyperGeometric::setState() { double z = pVariance / (pMean * pMean); pP = 0.5 * (1.0 - sqrt((z - 1.0) / ( z + 1.0 ))); } inline HyperGeometric::HyperGeometric(double mean, double variance, RNG *gen) : (gen) { pMean = mean; pVariance = variance; setState(); } inline double HyperGeometric::mean() { return pMean; }; inline double HyperGeometric::mean(double x) { double t = pMean; pMean = x; setState(); return t; } inline double HyperGeometric::variance() { return pVariance; } inline double HyperGeometric::variance(double x) { double t = pVariance; pVariance = x; setState(); return t; } //#endif #endif 0707070000020034711004440000020000020000010252610460564761200002500000012752g++-include/values.h// 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 _values_h #pragma once #define _values_h 1 #define BITSPERBYTE 8 #define BITS(type) (BITSPERBYTE * (int)sizeof(type)) #define CHARBITS BITS(char) #define SHORTBITS BITS(short) #define INTBITS BITS(int) #define LONGBITS BITS(long) #define PTRBITS BITS(char*) #define DOUBLEBITS BITS(double) #define FLOATBITS BITS(float) #define MINSHORT ((short)(1 << (SHORTBITS - 1))) #define MININT (1 << (INTBITS - 1)) #define MINLONG (1L << (LONGBITS - 1)) #define MAXSHORT ((short)~MINSHORT) #define MAXINT (~MININT) #define MAXLONG (~MINLONG) #if defined(sun) || defined(hp300) || defined(hpux) || defined(unixpc) #define MAXDOUBLE 1.79769313486231470e+308 #define MAXFLOAT ((float)3.40282346638528860e+38) #define MINDOUBLE 4.94065645841246544e-324 #define MINFLOAT ((float)1.40129846432481707e-45) #if defined(unixpc) #define _IEEE 0 #else #define _IEEE 1 #endif #define _DEXPLEN 11 #define _FEXPLEN 8 #define _HIDDENBIT 1 #define DMINEXP (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3)) #define FMINEXP (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3)) #define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE) #define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE) #elif defined(sony) #define MAXDOUBLE 1.79769313486231470e+308 #define MAXFLOAT ((float)3.40282346638528860e+38) #define MINDOUBLE 2.2250738585072010e-308 #define MINFLOAT ((float)1.17549435e-38) #define _IEEE 1 #define _DEXPLEN 11 #define _FEXPLEN 8 #define _HIDDENBIT 1 #define DMINEXP (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3)) #define FMINEXP (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3)) #define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE) #define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE) #elif defined(sequent) extern double _maxdouble, _mindouble; extern float _maxfloat, _minfloat; #define MAXDOUBLE _maxdouble #define MAXFLOAT _maxfloat #define MINDOUBLE _mindouble #define MINFLOAT _minfloat #define _IEEE 1 #define _DEXPLEN 11 #define _FEXPLEN 8 #define _HIDDENBIT 1 #define DMINEXP (-(DMAXEXP - 3)) #define FMINEXP (-(FMAXEXP - 3)) #define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE) #define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE) #elif defined(i386) #define MAXDOUBLE 1.79769313486231570e+308 #define MAXFLOAT ((float)3.40282346638528860e+38) #define MINDOUBLE 2.22507385850720140e-308 #define MINFLOAT ((float)1.17549435082228750e-38) #define _IEEE 0 #define _DEXPLEN 11 #define _FEXPLEN 8 #define _HIDDENBIT 1 #define DMINEXP (-DMAXEXP) #define FMINEXP (-FMAXEXP) #define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE) #define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE) /* from Andrew Klossner */ #elif defined(m88k) /* These are "good" guesses ... I'll figure out the true mins and maxes later, at the time I find out the mins and maxes that the compiler can tokenize. */ #define MAXDOUBLE 1.79769313486231e+308 #define MAXFLOAT ((float)3.40282346638528e+38) #define MINDOUBLE 2.22507385850720e-308 #define MINFLOAT ((float)1.17549435082228e-38) #define _IEEE 1 #define _DEXPLEN 11 #define _FEXPLEN 8 #define _HIDDENBIT 1 #define DMINEXP (1-DMAXEXP) #define FMINEXP (1-FMAXEXP) #define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE) #define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE) #elif defined(convex) #define MAXDOUBLE 8.9884656743115785e+306 #define MAXFLOAT ((float) 1.70141173e+38) #define MINDOUBLE 5.5626846462680035e-308 #define MINFLOAT ((float) 2.93873588e-39) #define _IEEE 0 #define _DEXPLEN 11 #define _FEXPLEN 8 #define _HIDDENBIT 1 #define DMINEXP (-DMAXEXP) #define FMINEXP (-FMAXEXP) #define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE) #define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE) // #elif defined(vax) // use vax versions by default -- they seem to be the most conservative #else #define MAXDOUBLE 1.701411834604692293e+38 #define MINDOUBLE (2.938735877055718770e-39) #define MAXFLOAT 1.7014117331926443e+38 #define MINFLOAT 2.9387358770557188e-39 #define _IEEE 0 #define _DEXPLEN 8 #define _FEXPLEN 8 #define _HIDDENBIT 1 #define DMINEXP (-DMAXEXP) #define FMINEXP (-FMAXEXP) #define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE) #define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE) #endif #define DSIGNIF (DOUBLEBITS - _DEXPLEN + _HIDDENBIT - 1) #define FSIGNIF (FLOATBITS - _FEXPLEN + _HIDDENBIT - 1) #define DMAXPOWTWO ((double)(1L << LONGBITS -2)*(1L << DSIGNIF - LONGBITS +1)) #define FMAXPOWTWO ((float)(1L << FSIGNIF - 1)) #endif 0707070000020174321004440000020000020000011321200460564761400003200000000530g++-include/Incremental.h#ifndef Incremental_h #pragma once #define Incremental_h #define DECLARE_INIT_FUNCTION(USER_INIT_FUNCTION) \ static void USER_INIT_FUNCTION (); extern void (*_initfn)(); \ static struct xyzzy { xyzzy () {_initfn = USER_INIT_FUNCTION;}; \ ~xyzzy () {};} __2xyzzy; #else #error Incremental.h was not the first file included in this module #endif 0707070000020120661004440000020000020000011132410460564761700002600000054510g++-include/Integer.h// 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 _Integer_h #pragma once #define _Integer_h 1 #include struct IntRep // internal Integer representations { unsigned short len; // current length unsigned short sz; // allocated space short sgn; // 1 means >= 0; 0 means < 0 unsigned short s[1]; // represented as ushort array starting here }; extern IntRep* Ialloc(IntRep*, const unsigned short *, int, int, int); extern IntRep* Icalloc(IntRep*, int); extern IntRep* Icopy_long(IntRep*, long); extern IntRep* Icopy(IntRep*, const IntRep*); extern IntRep* Iresize(IntRep*, int); extern IntRep* add(const IntRep*, int, const IntRep*, int, IntRep*); extern IntRep* add(const IntRep*, int, long, IntRep*); extern IntRep* multiply(const IntRep*, const IntRep*, IntRep*); extern IntRep* multiply(const IntRep*, long, IntRep*); extern IntRep* lshift(const IntRep*, long, IntRep*); extern IntRep* lshift(const IntRep*, const IntRep*, int, IntRep*); extern IntRep* bitop(const IntRep*, const IntRep*, IntRep*, char); extern IntRep* bitop(const IntRep*, long, IntRep*, char); extern IntRep* power(const IntRep*, long, IntRep*); extern IntRep* div(const IntRep*, const IntRep*, IntRep*); extern IntRep* mod(const IntRep*, const IntRep*, IntRep*); extern IntRep* div(const IntRep*, long, IntRep*); extern IntRep* mod(const IntRep*, long, IntRep*); extern IntRep* compl(const IntRep*, IntRep*); extern IntRep* abs(const IntRep*, IntRep*); extern IntRep* negate(const IntRep*, IntRep*); extern IntRep* pow(const IntRep*, long); extern IntRep* gcd(const IntRep*, const IntRep* y); extern int compare(const IntRep*, const IntRep*); extern int compare(const IntRep*, long); extern int ucompare(const IntRep*, const IntRep*); extern int ucompare(const IntRep*, long); extern char* Itoa(const IntRep* x, int base = 10, int width = 0); extern IntRep* atoIntRep(const char* s, int base = 10); extern long Itolong(const IntRep*); extern double Itodouble(const IntRep*); extern int Iislong(const IntRep*); extern int Iisdouble(const IntRep*); extern long lg(const IntRep*); class Integer { protected: IntRep* rep; public: Integer(); Integer(long); Integer(const Integer&); ~Integer(); void operator = (const Integer&); void operator = (long); // unary operations to self void operator ++ (); void operator -- (); void negate(); // negate in-place void abs(); // absolute-value in-place void complement(); // bitwise complement in-place // assignment-based operations void operator += (const Integer&); void operator -= (const Integer&); void operator *= (const Integer&); void operator /= (const Integer&); void operator %= (const Integer&); void operator <<=(const Integer&); void operator >>=(const Integer&); void operator &= (const Integer&); void operator |= (const Integer&); void operator ^= (const Integer&); void operator += (long); void operator -= (long); void operator *= (long); void operator /= (long); void operator %= (long); void operator <<=(long); void operator >>=(long); void operator &= (long); void operator |= (long); void operator ^= (long); // (constructive binary operations are inlined below) #ifdef __GNUG__ friend Integer operator ? (const Integer& x, const Integer& y); // max #endif // builtin Integer functions that must be friends friend long lg (const Integer&); // floor log base 2 of abs(x) friend double ratio(const Integer& x, const Integer& y); // return x/y as a double friend Integer gcd(const Integer&, const Integer&); friend int even(const Integer&); // true if even friend int odd(const Integer&); // true if odd friend int sign(const Integer&); // returns -1, 0, +1 friend void setbit(Integer& x, long b); // set b'th bit of x friend void clearbit(Integer& x, long b); // clear b'th bit friend int testbit(const Integer& x, long b); // return b'th bit // procedural versions of operators friend void abs(const Integer& x, Integer& dest); friend void negate(const Integer& x, Integer& dest); friend void complement(const Integer& x, Integer& dest); friend int compare(const Integer&, const Integer&); friend int ucompare(const Integer&, const Integer&); friend void add(const Integer& x, const Integer& y, Integer& dest); friend void sub(const Integer& x, const Integer& y, Integer& dest); friend void mul(const Integer& x, const Integer& y, Integer& dest); friend void div(const Integer& x, const Integer& y, Integer& dest); friend void mod(const Integer& x, const Integer& y, Integer& dest); friend void divide(const Integer& x, const Integer& y, Integer& q, Integer& r); friend void and(const Integer& x, const Integer& y, Integer& dest); friend void or(const Integer& x, const Integer& y, Integer& dest); friend void xor(const Integer& x, const Integer& y, Integer& dest); friend void lshift(const Integer& x, const Integer& y, Integer& dest); friend void rshift(const Integer& x, const Integer& y, Integer& dest); friend void pow(const Integer& x, const Integer& y, Integer& dest); friend int compare(const Integer&, long); friend int ucompare(const Integer&, long); friend void add(const Integer& x, long y, Integer& dest); friend void sub(const Integer& x, long y, Integer& dest); friend void mul(const Integer& x, long y, Integer& dest); friend void div(const Integer& x, long y, Integer& dest); friend void mod(const Integer& x, long y, Integer& dest); friend void divide(const Integer& x, long y, Integer& q, long& r); friend void and(const Integer& x, long y, Integer& dest); friend void or(const Integer& x, long y, Integer& dest); friend void xor(const Integer& x, long y, Integer& dest); friend void lshift(const Integer& x, long y, Integer& dest); friend void rshift(const Integer& x, long y, Integer& dest); friend void pow(const Integer& x, long y, Integer& dest); friend int compare(long, const Integer&); friend int ucompare(long, const Integer&); friend void add(long x, const Integer& y, Integer& dest); friend void sub(long x, const Integer& y, Integer& dest); friend void mul(long x, const Integer& y, Integer& dest); friend void and(long x, const Integer& y, Integer& dest); friend void or(long x, const Integer& y, Integer& dest); friend void xor(long x, const Integer& y, Integer& dest); // coercion & conversion int fits_in_long() const; int fits_in_double() const; operator long() const; operator double() const; friend char* Itoa(const Integer& x, int base = 10, int width = 0); friend Integer atoI(const char* s, int base = 10); friend istream& operator >> (istream& s, Integer& y); friend ostream& operator << (ostream& s, const Integer& y); // error detection int initialized() const; volatile void error(const char* msg) const; int OK() const; }; /* (These are declared inline below) int operator == (const Integer&, const Integer&); int operator == (const Integer&, long); int operator != (const Integer&, const Integer&); int operator != (const Integer&, long); int operator < (const Integer&, const Integer&); int operator < (const Integer&, long); int operator <= (const Integer&, const Integer&); int operator <= (const Integer&, long); int operator > (const Integer&, const Integer&); int operator > (const Integer&, long); int operator >= (const Integer&, const Integer&); int operator >= (const Integer&, long); Integer operator - (const Integer&); Integer operator ~ (const Integer&); Integer operator + (const Integer&, const Integer&); Integer operator + (const Integer&, long); Integer operator + (long, const Integer&); Integer operator - (const Integer&, const Integer&); Integer operator - (const Integer&, long); Integer operator - (long, const Integer&); Integer operator * (const Integer&, const Integer&); Integer operator * (const Integer&, long); Integer operator * (long, const Integer&); Integer operator / (const Integer&, const Integer&); Integer operator / (const Integer&, long); Integer operator % (const Integer&, const Integer&); Integer operator % (const Integer&, long); Integer operator << (const Integer&, const Integer&); Integer operator << (const Integer&, long); Integer operator >> (const Integer&, const Integer&); Integer operator >> (const Integer&, long); Integer operator & (const Integer&, const Integer&); Integer operator & (const Integer&, long); Integer operator & (long, const Integer&); Integer operator | (const Integer&, const Integer&); Integer operator | (const Integer&, long); Integer operator | (long, const Integer&); Integer operator ^ (const Integer&, const Integer&); Integer operator ^ (const Integer&, long); Integer operator ^ (long, const Integer&); Integer abs(const Integer&); // absolute value Integer sqr(const Integer&); // square Integer pow(const Integer& x, const Integer& y); Integer pow(const Integer& x, long y); Integer Ipow(long x, long y); // x to the y as Integer */ extern char* dec(const Integer& x, int width = 0); extern char* oct(const Integer& x, int width = 0); extern char* hex(const Integer& x, int width = 0); extern Integer sqrt(const Integer&); // floor of square root extern Integer lcm(const Integer& x, const Integer& y); // least common mult typedef Integer IntTmp; // for backward compatibility //#ifdef __OPTIMIZE__ inline Integer::Integer() :rep(0) {} inline Integer::Integer(long y) :rep(Icopy_long(0, y)) {} inline Integer::Integer(const Integer& y) :rep(Icopy(0, y.rep)) {} inline Integer::~Integer() { delete rep; } inline void Integer::operator = (const Integer& y) { rep = Icopy(rep, y.rep); } inline void Integer::operator = (long y) { rep = Icopy_long(rep, y); } inline Integer::operator long() const { return Itolong(rep); } inline int Integer::initialized() const { return rep != 0; } inline int Integer::fits_in_long() const { return Iislong(rep); } inline Integer::operator double() const { return Itodouble(rep); } inline int Integer::fits_in_double() const { return Iisdouble(rep); } // procedural versions inline int compare(const Integer& x, const Integer& y) { return compare(x.rep, y.rep); } inline int ucompare(const Integer& x, const Integer& y) { return ucompare(x.rep, y.rep); } inline int compare(const Integer& x, long y) { return compare(x.rep, y); } inline int ucompare(const Integer& x, long y) { return ucompare(x.rep, y); } inline int compare(long x, const Integer& y) { return -compare(y.rep, x); } inline int ucompare(long x, const Integer& y) { return -ucompare(y.rep, x); } inline void add(const Integer& x, const Integer& y, Integer& dest) { dest.rep = add(x.rep, 0, y.rep, 0, dest.rep); } inline void sub(const Integer& x, const Integer& y, Integer& dest) { dest.rep = add(x.rep, 0, y.rep, 1, dest.rep); } inline void mul(const Integer& x, const Integer& y, Integer& dest) { dest.rep = multiply(x.rep, y.rep, dest.rep); } inline void div(const Integer& x, const Integer& y, Integer& dest) { dest.rep = div(x.rep, y.rep, dest.rep); } inline void mod(const Integer& x, const Integer& y, Integer& dest) { dest.rep = mod(x.rep, y.rep, dest.rep); } inline void and(const Integer& x, const Integer& y, Integer& dest) { dest.rep = bitop(x.rep, y.rep, dest.rep, '&'); } inline void or(const Integer& x, const Integer& y, Integer& dest) { dest.rep = bitop(x.rep, y.rep, dest.rep, '|'); } inline void xor(const Integer& x, const Integer& y, Integer& dest) { dest.rep = bitop(x.rep, y.rep, dest.rep, '^'); } inline void lshift(const Integer& x, const Integer& y, Integer& dest) { dest.rep = lshift(x.rep, y.rep, 0, dest.rep); } inline void rshift(const Integer& x, const Integer& y, Integer& dest) { dest.rep = lshift(x.rep, y.rep, 1, dest.rep); } inline void pow(const Integer& x, const Integer& y, Integer& dest) { dest.rep = power(x.rep, long(y), dest.rep); // not incorrect } inline void add(const Integer& x, long y, Integer& dest) { dest.rep = add(x.rep, 0, y, dest.rep); } inline void sub(const Integer& x, long y, Integer& dest) { dest.rep = add(x.rep, 0, -y, dest.rep); } inline void mul(const Integer& x, long y, Integer& dest) { dest.rep = multiply(x.rep, y, dest.rep); } inline void div(const Integer& x, long y, Integer& dest) { dest.rep = div(x.rep, y, dest.rep); } inline void mod(const Integer& x, long y, Integer& dest) { dest.rep = mod(x.rep, y, dest.rep); } inline void and(const Integer& x, long y, Integer& dest) { dest.rep = bitop(x.rep, y, dest.rep, '&'); } inline void or(const Integer& x, long y, Integer& dest) { dest.rep = bitop(x.rep, y, dest.rep, '|'); } inline void xor(const Integer& x, long y, Integer& dest) { dest.rep = bitop(x.rep, y, dest.rep, '^'); } inline void lshift(const Integer& x, long y, Integer& dest) { dest.rep = lshift(x.rep, y, dest.rep); } inline void rshift(const Integer& x, long y, Integer& dest) { dest.rep = lshift(x.rep, -y, dest.rep); } inline void pow(const Integer& x, long y, Integer& dest) { dest.rep = power(x.rep, y, dest.rep); } inline void abs(const Integer& x, Integer& dest) { dest.rep = abs(x.rep, dest.rep); } inline void negate(const Integer& x, Integer& dest) { dest.rep = negate(x.rep, dest.rep); } inline void complement(const Integer& x, Integer& dest) { dest.rep = compl(x.rep, dest.rep); } inline void add(long x, const Integer& y, Integer& dest) { dest.rep = add(y.rep, 0, x, dest.rep); } inline void sub(long x, const Integer& y, Integer& dest) { dest.rep = add(y.rep, 1, x, dest.rep); } inline void mul(long x, const Integer& y, Integer& dest) { dest.rep = multiply(y.rep, x, dest.rep); } inline void and(long x, const Integer& y, Integer& dest) { dest.rep = bitop(y.rep, x, dest.rep, '&'); } inline void or(long x, const Integer& y, Integer& dest) { dest.rep = bitop(y.rep, x, dest.rep, '|'); } inline void xor(long x, const Integer& y, Integer& dest) { dest.rep = bitop(y.rep, x, dest.rep, '^'); } // operator versions inline int operator == (const Integer& x, const Integer& y) { return compare(x, y) == 0; } inline int operator == (const Integer& x, long y) { return compare(x, y) == 0; } inline int operator != (const Integer& x, const Integer& y) { return compare(x, y) != 0; } inline int operator != (const Integer& x, long y) { return compare(x, y) != 0; } inline int operator < (const Integer& x, const Integer& y) { return compare(x, y) < 0; } inline int operator < (const Integer& x, long y) { return compare(x, y) < 0; } inline int operator <= (const Integer& x, const Integer& y) { return compare(x, y) <= 0; } inline int operator <= (const Integer& x, long y) { return compare(x, y) <= 0; } inline int operator > (const Integer& x, const Integer& y) { return compare(x, y) > 0; } inline int operator > (const Integer& x, long y) { return compare(x, y) > 0; } inline int operator >= (const Integer& x, const Integer& y) { return compare(x, y) >= 0; } inline int operator >= (const Integer& x, long y) { return compare(x, y) >= 0; } inline Integer operator + (const Integer& x, const Integer& y) return r { add(x, y, r); } inline Integer operator + (const Integer& x, long y) return r { add(x, y, r); } inline Integer operator + (long x, const Integer& y) return r { add(x, y, r); } inline void Integer::operator += (const Integer& y) { add(*this, y, *this); } inline void Integer::operator += (long y) { add(*this, y, *this); } inline void Integer::operator ++ () { add(*this, 1, *this); } inline Integer operator - (const Integer& x, const Integer& y) return r { sub(x, y, r); } inline Integer operator - (const Integer& x, long y) return r { sub(x, y, r); } inline Integer operator - (long x, const Integer& y) return r { sub(x, y, r); } inline void Integer::operator -= (const Integer& y) { sub(*this, y, *this); } inline void Integer::operator -= (long y) { sub(*this, y, *this); } inline void Integer::operator -- () { add(*this, -1, *this); } inline Integer operator * (const Integer& x, const Integer& y) return r { mul(x, y, r); } inline Integer operator * (const Integer& x, long y) return r { mul(x, y, r); } inline Integer operator * (long x, const Integer& y) return r { mul(x, y, r); } inline void Integer::operator *= (const Integer& y) { mul(*this, y, *this); } inline void Integer::operator *= (long y) { mul(*this, y, *this); } inline Integer sqr(const Integer& x) return r { mul(x, x, r); } inline Integer operator & (const Integer& x, const Integer& y) return r { and(x, y, r); } inline Integer operator & (const Integer& x, long y) return r { and(x, y, r); } inline Integer operator & (long x, const Integer& y) return r { and(x, y, r); } inline void Integer::operator &= (const Integer& y) { and(*this, y, *this); } inline void Integer::operator &= (long y) { and(*this, y, *this); } inline Integer operator | (const Integer& x, const Integer& y) return r { or(x, y, r); } inline Integer operator | (const Integer& x, long y) return r { or(x, y, r); } inline Integer operator | (long x, const Integer& y) return r { or(x, y, r); } inline void Integer::operator |= (const Integer& y) { or(*this, y, *this); } inline void Integer::operator |= (long y) { or(*this, y, *this); } inline Integer operator ^ (const Integer& x, const Integer& y) return r { xor(x, y, r); } inline Integer operator ^ (const Integer& x, long y) return r { xor(x, y, r); } inline Integer operator ^ (long x, const Integer& y) return r { xor(x, y, r); } inline void Integer::operator ^= (const Integer& y) { xor(*this, y, *this); } inline void Integer::operator ^= (long y) { xor(*this, y, *this); } inline Integer operator / (const Integer& x, const Integer& y) return r { div(x, y, r); } inline Integer operator / (const Integer& x, long y) return r { div(x, y, r); } inline void Integer::operator /= (const Integer& y) { div(*this, y, *this); } inline void Integer::operator /= (long y) { div(*this, y, *this); } inline Integer operator % (const Integer& x, const Integer& y) return r { mod(x, y, r); } inline Integer operator % (const Integer& x, long y) return r { mod(x, y, r); } inline void Integer::operator %= (const Integer& y) { mod(*this, y, *this); } inline void Integer::operator %= (long y) { mod(*this, y, *this); } inline Integer operator << (const Integer& x, const Integer& y) return r { lshift(x, y, r); } inline Integer operator << (const Integer& x, long y) return r { lshift(x, y, r); } inline void Integer::operator <<= (const Integer& y) { lshift(*this, y, *this); } inline void Integer::operator <<= (long y) { lshift(*this, y, *this); } inline Integer operator >> (const Integer& x, const Integer& y) return r; { rshift(x, y, r); } inline Integer operator >> (const Integer& x, long y) return r { rshift(x, y, r); } inline void Integer::operator >>= (const Integer& y) { rshift(*this, y, *this); } inline void Integer::operator >>= (long y) { rshift(*this, y, *this); } #ifdef __GNUG__ inline Integer operator ? (const Integer& x, const Integer& y) { return (compare(x.rep, y.rep) >= 0)? x : y; } #endif inline Integer pow(const Integer& x, long y) return r { pow(x, y, r); } inline Integer Ipow(long x, long y) return r(x) { pow(r, y, r); } inline Integer pow(const Integer& x, const Integer& y) return r { pow(x, y, r); } inline Integer abs(const Integer& x) return r { abs(x, r); } inline void Integer::abs() { ::abs(*this, *this); } inline void Integer::negate() { ::negate(*this, *this); } inline Integer operator - (const Integer& x) return r { negate(x, r); } inline void Integer::complement() { ::complement(*this, *this); } inline Integer operator ~ (const Integer& x) return r { complement(x, r); } inline int sign(const Integer& x) { return (x.rep->len == 0) ? 0 : ( (x.rep->sgn == 1) ? 1 : -1 ); } inline int even(const Integer& y) { return y.rep->len == 0 || !(y.rep->s[0] & 1); } inline int odd(const Integer& y) { return y.rep->len > 0 && (y.rep->s[0] & 1); } inline char* Itoa(const Integer& y, int base, int width) { return Itoa(y.rep, base, width); } inline Integer atoI(const char* s, int base) return r { r.rep = atoIntRep(s, base); } inline ostream& operator << (ostream& s, const Integer& y) { return s << Itoa(y.rep); } inline Integer gcd(const Integer& x, const Integer& y) return r { r.rep = gcd(x.rep, y.rep); } inline long lg(const Integer& x) { return lg(x.rep); } //#endif #endif 0707070000020012571004440000020000020000010120010460564762100003000000004023g++-include/LogNormal.h// 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) 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 _LogNormal_h #pragma once #define _LogNormal_h #include "Normal.h" class LogNormal: public Normal { protected: double logMean; double logVariance; void setState(); public: LogNormal(double mean, double variance, RNG *gen); inline double mean(); inline double mean(double x); inline double variance(); inline double variance(double x); virtual double operator()(); }; //#ifdef __OPTIMIZE__ inline void LogNormal::setState() { double m2 = logMean * logMean; pMean = log(m2 / sqrt(logVariance + m2) ); pVariance = log((sqrt(logVariance + m2)/m2 )); } inline LogNormal::LogNormal(double mean, double variance, RNG *gen) : (mean, variance, gen) { logMean = mean; logVariance = variance; setState(); } inline double LogNormal::mean() { return logMean; } inline double LogNormal::mean(double x) { double t=logMean; logMean = x; setState(); return t; } inline double LogNormal::variance() { return logVariance; } inline double LogNormal::variance(double x) { double t=logVariance; logVariance = x; setState(); return t; } #endif 0707070000020012241004440000020000020000011167250460564762300002400000031174g++-include/regex.h/* Definitions for data structures callers pass the regex library. Copyright (C) 1985 Free Software Foundation, Inc. NO WARRANTY BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. GENERAL PUBLIC LICENSE TO COPY 1. You may copy and distribute verbatim copies of this source file as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy a valid copyright notice "Copyright (C) 1985 Free Software Foundation, Inc."; and include following the copyright notice a verbatim copy of the above disclaimer of warranty and of this License. You may charge a distribution fee for the physical act of transferring a copy. 2. You may modify your copy or copies of this source file or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains or is a derivative of this program or any part thereof, to be licensed at no charge to all third parties on terms identical to those contained in this License Agreement (except that you may choose to grant more extensive warranty protection to some or all third parties, at your option). c) You may charge a distribution fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another unrelated program with this program (or its derivative) on a volume of a storage or distribution medium does not bring the other program under the scope of these terms. 3. You may copy and distribute this program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal shipping charge) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs. 4. You may not copy, sublicense, distribute or transfer this program except as expressly provided under this License Agreement. Any attempt otherwise to copy, sublicense, distribute or transfer this program is void and your rights to use the program under this License agreement shall be automatically terminated. However, parties who have received computer software programs from you with this License Agreement will not have their licenses terminated so long as such parties remain in full compliance. 5. If you wish to incorporate parts of this program into other free programs whose distribution conditions are different, write to the Free Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet worked out a simple rule that can be stated here, but we will often permit this. We will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software. In other words, you are welcome to use, share and improve this program. You are forbidden to forbid anyone else to use, share and improve what you give them. Help stamp out software-hoarding! */ /* Define number of parens for which we record the beginnings and ends. This affects how much space the `struct re_registers' type takes up. */ #ifndef RE_NREGS #define RE_NREGS 10 #endif /* These bits are used in the obscure_syntax variable to choose among alternative regexp syntaxes. */ /* 1 means plain parentheses serve as grouping, and backslash parentheses are needed for literal searching. 0 means backslash-parentheses are grouping, and plain parentheses are for literal searching. */ #define RE_NO_BK_PARENS 1 /* 1 means plain | serves as the "or"-operator, and \| is a literal. 0 means \| serves as the "or"-operator, and | is a literal. */ #define RE_NO_BK_VBAR 2 /* 0 means plain + or ? serves as an operator, and \+, \? are literals. 1 means \+, \? are operators and plain +, ? are literals. */ #define RE_BK_PLUS_QM 4 /* 1 means | binds tighter than ^ or $. 0 means the contrary. */ #define RE_TIGHT_VBAR 8 /* 1 means treat \n as an _OR operator 0 means treat it as a normal character */ #define RE_NEWLINE_OR 16 /* 0 means that a special characters (such as *, ^, and $) always have their special meaning regardless of the surrounding context. 1 means that special characters may act as normal characters in some contexts. Specifically, this applies to: ^ - only special at the beginning, or after ( or | $ - only special at the end, or before ) or | *, +, ? - only special when not after the beginning, (, or | */ #define RE_CONTEXT_INDEP_OPS 32 /* Now define combinations of bits for the standard possibilities. */ #define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS) #define RE_SYNTAX_EGREP (RE_SYNTAX_AWK | RE_NEWLINE_OR) #define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR) #define RE_SYNTAX_EMACS 0 /* This data structure is used to represent a compiled pattern. */ struct re_pattern_buffer { char *buffer; /* Space holding the compiled pattern commands. */ int allocated; /* Size of space that buffer points to */ int used; /* Length of portion of buffer actually occupied */ char *fastmap; /* Pointer to fastmap, if any, or zero if none. */ /* re_search uses the fastmap, if there is one, to skip quickly over totally implausible characters */ char *translate; /* Translate table to apply to all characters before comparing. Or zero for no translation. The translation is applied to a pattern when it is compiled and to data when it is matched. */ char fastmap_accurate; /* Set to zero when a new pattern is stored, set to one when the fastmap is updated from it. */ char can_be_null; /* Set to one by compiling fastmap if this pattern might match the null string. It does not necessarily match the null string in that case, but if this is zero, it cannot. 2 as value means can match null string but at end of range or before a character listed in the fastmap. */ }; /* Structure to store "register" contents data in. Pass the address of such a structure as an argument to re_match, etc., if you want this information back. start[i] and end[i] record the string matched by \( ... \) grouping i, for i from 1 to RE_NREGS - 1. start[0] and end[0] record the entire string matched. */ struct re_registers { int start[RE_NREGS]; int end[RE_NREGS]; }; /* These are the command codes that appear in compiled regular expressions, one per byte. Some command codes are followed by argument bytes. A command code can specify any interpretation whatever for its arguments. Zero-bytes may appear in the compiled regular expression. */ enum regexpcode { unused, exactn, /* followed by one byte giving n, and then by n literal bytes */ begline, /* fails unless at beginning of line */ endline, /* fails unless at end of line */ jump, /* followed by two bytes giving relative address to jump to */ on_failure_jump, /* followed by two bytes giving relative address of place to resume at in case of failure. */ finalize_jump, /* Throw away latest failure point and then jump to address. */ maybe_finalize_jump, /* Like jump but finalize if safe to do so. This is used to jump back to the beginning of a repeat. If the command that follows this jump is clearly incompatible with the one at the beginning of the repeat, such that we can be sure that there is no use backtracking out of repetitions already completed, then we finalize. */ dummy_failure_jump, /* jump, and push a dummy failure point. This failure point will be thrown away if an attempt is made to use it for a failure. A + construct makes this before the first repeat. */ anychar, /* matches any one character */ charset, /* matches any one char belonging to specified set. First following byte is # bitmap bytes. Then come bytes for a bit-map saying which chars are in. Bits in each byte are ordered low-bit-first. A character is in the set if its bit is 1. A character too large to have a bit in the map is automatically not in the set */ charset_not, /* similar but match any character that is NOT one of those specified */ start_memory, /* starts remembering the text that is matched and stores it in a memory register. followed by one byte containing the register number. Register numbers must be in the range 0 through NREGS. */ stop_memory, /* stops remembering the text that is matched and stores it in a memory register. followed by one byte containing the register number. Register numbers must be in the range 0 through NREGS. */ duplicate, /* match a duplicate of something remembered. Followed by one byte containing the index of the memory register. */ before_dot, /* Succeeds if before dot */ at_dot, /* Succeeds if at dot */ after_dot, /* Succeeds if after dot */ begbuf, /* Succeeds if at beginning of buffer */ endbuf, /* Succeeds if at end of buffer */ wordchar, /* Matches any word-constituent character */ notwordchar, /* Matches any char that is not a word-constituent */ wordbeg, /* Succeeds if at word beginning */ wordend, /* Succeeds if at word end */ wordbound, /* Succeeds if at a word boundary */ notwordbound, /* Succeeds if not at a word boundary */ syntaxspec, /* Matches any character whose syntax is specified. followed by a byte which contains a syntax code, Sword or such like */ notsyntaxspec /* Matches any character whose syntax differs from the specified. */ }; extern char *re_compile_pattern (char*, int, struct re_pattern_buffer*); /* Is this really advertised? */ extern void re_compile_fastmap (struct re_pattern_buffer*); extern int re_search(struct re_pattern_buffer*, char*, int, int, int, struct re_registers*); extern int re_search_2 (struct re_pattern_buffer*, char*, int, char*, int, int, int, struct re_registers*, int); extern int re_match (struct re_pattern_buffer*, char*, int, int, struct re_registers*); extern int re_match_2 (struct re_pattern_buffer*, unsigned char*, int, unsigned char*, int, int, struct re_registers*, int); /* 4.2 bsd compatibility (yuck) */ extern char *re_comp (char*); extern int re_exec (char*); #ifdef SYNTAX_TABLE extern char *re_syntax_table; #endif 0707070000020123121004440000020000020000010073370460564762600002300000003504g++-include/MLCG.h// 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) 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 _MLCG_h #define _MLCG_h 1 #pragma once #include #include // // Multiplicative Linear Conguential Generator // class MLCG : public RNG { long initialSeedOne; long initialSeedTwo; long seedOne; long seedTwo; protected: public: MLCG(long seed1 = 0, long seed2 = 1); // // Return a long-words word of random bits // virtual unsigned long asLong(); virtual void reset(); long seed1(); void seed1(long); long seed2(); void seed2(long); void reseed(long, long); }; inline long MLCG::seed1() { return(seedOne); } inline void MLCG::seed1(long s) { initialSeedOne = s; reset(); } inline long MLCG::seed2() { return(seedTwo); } inline void MLCG::seed2(long s) { initialSeedTwo = s; reset(); } inline void MLCG::reseed(long s1, long s2) { initialSeedOne = s1; initialSeedTwo = s2; reset(); } #endif 0707070000020004401004440000020000020000010766600460564763000003300000003030g++-include/NegativeExpntl// 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) 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 _NegativeExpntl_h #pragma once #define _NegativeExpntl_h 1 // // Negative Exponential Random Numbers // // #include class NegativeExpntl: public Random { protected: double pMean; public: NegativeExpntl(double xmean, RNG *gen); double mean(); double mean(double x); virtual double operator()(); }; //ifdef __OPTIMIZE__ inline NegativeExpntl::NegativeExpntl(double xmean, RNG *gen) : (gen) { pMean = xmean; } inline double NegativeExpntl::mean() { return pMean; } inline double NegativeExpntl::mean(double x) { double t = pMean; pMean = x; return t; } //endif #endif 0707070000020000151004440000020000020000011473240460564763200002500000003543g++-include/Normal.h// 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) 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 _Normal_h #pragma once #define _Normal_h #include class Normal: public Random { char haveCachedNormal; double cachedNormal; protected: double pMean; double pVariance; double pStdDev; public: Normal(double xmean, double xvariance, RNG *gen); double mean(); double mean(double x); double variance(); double variance(double x); virtual double operator()(); }; //#ifdef __OPTIMIZE__ inline Normal::Normal(double xmean, double xvariance, RNG *gen) : (gen) { pMean = xmean; pVariance = xvariance; pStdDev = sqrt(pVariance); haveCachedNormal = 0; } inline double Normal::mean() { return pMean; }; inline double Normal::mean(double x) { double t=pMean; pMean = x; return t; } inline double Normal::variance() { return pVariance; } inline double Normal::variance(double x) { double t=pVariance; pVariance = x; pStdDev = sqrt(pVariance); return t; }; //#endif #endif 0707070000020176231004440000020000020000010746220460564763400002600000010536g++-include/Obstack.h// 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 _Obstack_h #pragma once #define _Obstack_h 1 #include class Obstack { struct _obstack_chunk { char* limit; _obstack_chunk* prev; char contents[4]; }; protected: long chunksize; _obstack_chunk* chunk; char* objectbase; char* nextfree; char* chunklimit; int alignmentmask; void _free(void* obj); void newchunk(int size); public: Obstack(int size = 4080, int alignment = 4); // 4080=4096-mallocslop ~Obstack(); void* base(); void* next_free(); int alignment_mask(); int chunk_size(); int size(); int room(); int contains(void* p); // does Obstack hold pointer p? void grow(const void* data, int size); void grow(const void* data, int size, char terminator); void grow(const char* s); void grow(char c); void grow_fast(char c); void blank(int size); void blank_fast(int size); void* finish(); void* finish(char terminator); void* copy(const void* data, int size); void* copy(const void* data, int size, char terminator); void* copy(const char* s); void* copy(char c); void* alloc(int size); void free(void* obj); void shrink(int size = 1); // suggested by ken@cs.rochester.edu int OK(); // rep invariant }; //#ifdef __OPTIMIZE__ inline Obstack::~Obstack() { _free(0); } inline void* Obstack::base() { return objectbase; } inline void* Obstack::next_free() { return nextfree; } inline int Obstack::alignment_mask() { return alignmentmask; } inline int Obstack::chunk_size() { return chunksize; } inline int Obstack::size() { return nextfree - objectbase; } inline int Obstack::room() { return chunklimit - nextfree; } inline void Obstack:: grow(const void* data, int size) { if (nextfree+size > chunklimit) newchunk(size); bcopy(data, nextfree, size); nextfree += size; } inline void Obstack:: grow(const void* data, int size, char terminator) { if (nextfree+size+1 > chunklimit) newchunk(size+1); bcopy(data, nextfree, size); nextfree += size; *(nextfree)++ = terminator; } inline void Obstack:: grow(const char* s) { grow((void*)s, strlen(s), 0); } inline void Obstack:: grow(char c) { if (nextfree+1 > chunklimit) newchunk(1); *(nextfree)++ = c; } inline void Obstack:: blank(int size) { if (nextfree+size > chunklimit) newchunk(size); nextfree += size; } inline void* Obstack::finish(char terminator) { grow(terminator); return finish(); } inline void* Obstack::copy(const void* data, int size) { grow (data, size); return finish(); } inline void* Obstack::copy(const void* data, int size, char terminator) { grow(data, size, terminator); return finish(); } inline void* Obstack::copy(const char* s) { grow((void*)s, strlen(s), 0); return finish(); } inline void* Obstack::copy(char c) { grow(c); return finish(); } inline void* Obstack::alloc(int size) { blank(size); return finish(); } inline void Obstack:: free(void* obj) { if (obj >= (void*)chunk && obj<(void*)chunklimit) nextfree = objectbase = (char *) obj; else _free(obj); } inline void Obstack:: grow_fast(char c) { *(nextfree)++ = c; } inline void Obstack:: blank_fast(int size) { nextfree += size; } inline void Obstack:: shrink(int size) // from ken@cs.rochester.edu { if (nextfree >= objectbase + size) nextfree -= size; } //#endif #endif 0707070000020176241004440000020000020000011123130460564763600002200000000110g++-include/Pix.h #ifndef _Pix_h #pragma once #define _Pix_h 1 typedef void* Pix; #endif 0707070000020176251004440000020000020000011242100460564764000002700000006416g++-include/PlotFile.h// 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. */ /* a very simple implementation of a class to output unix "plot" format plotter files. See corresponding unix man pages for more details. */ #ifndef _PlotFile_h #pragma once #define _PlotFile_h #include /* Some plot libraries have the `box' command to draw boxes. Some don't. `box' is included here via moves & lines to allow both possiblilties. */ class PlotFile : private File { protected: PlotFile& cmd(char c); PlotFile& operator << (const int x); PlotFile& operator << (const char *s); public: File::close; File::raw; File::remove; File::filedesc; File::is_open; File::iocount; File::error; File::name; File::setname; File::rdstate; File::eof; File::fail; File::bad; File::good; File::clear; File::failif; File::writable; File::readable; PlotFile(); PlotFile(const char* filename, io_mode m, access_mode a); PlotFile(const char* filename, const char* m); PlotFile(int filedesc, io_mode m = io_writeonly); PlotFile(FILE* fileptr); ~PlotFile(); operator void*(); PlotFile& open(const char* filename, const io_mode m, const access_mode a); PlotFile& open(const char* filename, const char* m); PlotFile& open(const int filedesc, const io_mode m); PlotFile& open(FILE* fileptr); PlotFile& setbuf(const int buffer_kind); // vals: _IONBF, _IOFBF, _IOLBF PlotFile& setbuf(const int size, char* buf); PlotFile& arc(const int xi, const int yi, const int x0, const int y0, const int x1, const int y1); PlotFile& box(const int x0, const int y0, const int x1, const int y1); PlotFile& circle(const int x, const int y, const int r); PlotFile& cont(const int xi, const int yi); PlotFile& dot(const int xi, const int yi, const int dx, int n, const int* pat); PlotFile& erase(); PlotFile& label(const char* s); PlotFile& line(const int x0, const int y0, const int x1, const int y1); PlotFile& linemod(const char* s); PlotFile& move(const int xi, const int yi); PlotFile& point(const int xi, const int yi); PlotFile& space(const int x0, const int y0, const int x1, const int y1); }; #endif 0707070000020176261004440000020000020000011507460460564764200002600000002656g++-include/Poisson.h// 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) 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 _Poisson_h #pragma once #define _Poisson_h #include class Poisson: public Random { protected: double pMean; public: Poisson(double mean, RNG *gen); double mean(); double mean(double x); virtual double operator()(); }; //#ifdef __OPTIMIZE__ inline Poisson::Poisson(double mean, RNG *gen) : (gen) { pMean = mean; } inline double Poisson::mean() { return pMean; } inline double Poisson::mean(double x) { double t = pMean; pMean = x; return t; } //#endif #endif 0707070000020176271004440000020000020000011620760460564764600002200000004367g++-include/RNG.h// 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) 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 _RNG_h #pragma once #define _RNG_h 1 #pragma once #include #include union PrivateRNGSingleType { // used to access floats as unsigneds float s; unsigned long u; }; union PrivateRNGDoubleType { // used to access doubles as unsigneds double d; unsigned long u[2]; }; // // Base class for Random Number Generators. See ACG and MLCG for instances. // class RNG { static PrivateRNGSingleType singleMantissa; // mantissa bit vector static PrivateRNGDoubleType doubleMantissa; // mantissa bit vector public: RNG(); // // Return a long-words word of random bits // virtual unsigned long asLong() = 0; virtual void reset() = 0; // // Return random bits converted to either a float or a double // float asFloat(); double asDouble(); }; inline float RNG::asFloat() { PrivateRNGSingleType result; result.s = 1.0; result.u |= (asLong() & singleMantissa.u); result.s -= 1.0; assert( result.s < 1.0 && result.s >= 0); return( result.s ); } inline double RNG::asDouble() { PrivateRNGDoubleType result; result.d = 1.0; result.u[0] |= (asLong() & doubleMantissa.u[0]); result.u[1] |= (asLong() & doubleMantissa.u[1]); result.d -= 1.0; assert( result.d < 1.0 && result.d >= 0); return( result.d ); } #endif 0707070000020176301004440000020000020000010704550460564765000002500000002576g++-include/Random.h// 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) 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 _Random_h #pragma once #define _Random_h 1 #pragma once #include #include "RNG.h" class Random { protected: RNG *pGenerator; public: Random(RNG *generator); virtual double operator()() = 0; RNG *generator(); void generator(RNG *p); }; inline Random::Random(RNG *gen) { pGenerator = gen; } inline RNG *Random::generator() { return(pGenerator); } inline void Random::generator(RNG *p) { pGenerator = p; } #endif 0707070000020176311004440000020000020000010626030460564765200003300000003513g++-include/RandomInterval// 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) 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 _RandomInterval_h #pragma once #define _RandomInterval_h 1 #include // // The interval [lo..hi] // class RandomInterval: public Random { protected: double pLow; double pHigh; public: RandomInterval(double low, double high, RNG *gen); double low(); double low(double x); double high(); double high(double x); virtual double operator()(); }; //#ifdef __OPTIMIZE__ inline RandomInterval::RandomInterval(double low, double high, RNG *gen) : (gen) { if (low < high) { pLow = low; pHigh = high; } else { pLow = high; pHigh = low; } } inline double RandomInterval::low() { return pLow; } inline double RandomInterval::low(double x) { double tmp = pLow; pLow = x; return tmp; } inline double RandomInterval::high() { return pHigh; } inline double RandomInterval::high(double x) { double tmp = pHigh; pHigh = x; return tmp; } //#endif #endif 0707070000020176321004440000020000020000011217760460564765400003200000003451g++-include/RandomRange.h// 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) 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 _RandomRange_h #pragma once #define _RandomRange_h 1 #include // // The interval [lo..hi) // class RandomRange: public Random { protected: double pLow; double pHigh; public: RandomRange(double low, double high, RNG *gen); double low(); double low(double x); double high(); double high(double x); virtual double operator()(); }; //#ifdef __OPTIMIZE__ inline RandomRange::RandomRange(double low, double high, RNG *gen) : (gen) { if (low > high) { pHigh = low; pLow = high; } else { pLow = low; pHigh = high; } } inline double RandomRange::low() { return pLow; } inline double RandomRange::low(double x) { double tmp = pLow; pLow = x; return tmp; } inline double RandomRange::high() { return pHigh; } inline double RandomRange::high(double x) { double tmp = pHigh; pHigh = x; return tmp; } //#endif #endif 0707070000020176331004440000020000020000010715400460564765600002700000014751g++-include/Rational.h// 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 _Rational_h #pragma once #define _Rational_h 1 #include #include class Rational { protected: Integer num; Integer den; void normalize(); public: Rational(); Rational(double); Rational(long n, long d = 1); Rational(const Integer& n); Rational(const Integer& n, const Integer& d); Rational(const Rational&); ~Rational(); void operator = (const Rational& y); friend int operator == (const Rational& x, const Rational& y); friend int operator != (const Rational& x, const Rational& y); friend int operator < (const Rational& x, const Rational& y); friend int operator <= (const Rational& x, const Rational& y); friend int operator > (const Rational& x, const Rational& y); friend int operator >= (const Rational& x, const Rational& y); friend Rational operator + (const Rational& x, const Rational& y); friend Rational operator - (const Rational& x, const Rational& y); friend Rational operator * (const Rational& x, const Rational& y); friend Rational operator / (const Rational& x, const Rational& y); void operator += (const Rational& y); void operator -= (const Rational& y); void operator *= (const Rational& y); void operator /= (const Rational& y); #ifdef __GNUG__ friend Rational operator ? (const Rational& x, const Rational& y); // max #endif friend Rational operator - (const Rational& x); // builtin Rational functions void negate(); // x = -x void invert(); // x = 1/x friend int sign(const Rational& x); // -1, 0, or +1 friend Rational abs(const Rational& x); // absolute value friend Rational sqr(const Rational& x); // square friend Rational pow(const Rational& x, long y); friend Rational pow(const Rational& x, Integer& y); const Integer& numerator() const; const Integer& denominator() const; // coercion & conversion operator double() const; friend Integer floor(const Rational& x); friend Integer ceil(const Rational& x); friend Integer trunc(const Rational& x); friend Integer round(const Rational& x); friend istream& operator >> (istream& s, Rational& y); friend ostream& operator << (ostream& s, const Rational& y); // procedural versions of operators friend int compare(const Rational& x, const Rational& y); friend void add(const Rational& x, const Rational& y, Rational& dest); friend void sub(const Rational& x, const Rational& y, Rational& dest); friend void mul(const Rational& x, const Rational& y, Rational& dest); friend void div(const Rational& x, const Rational& y, Rational& dest); // error detection volatile void error(const char* msg) const; int OK() const; }; typedef Rational RatTmp; // backwards compatibility //#ifdef __OPTIMIZE__ inline Rational::Rational() {} inline Rational::~Rational() {} inline Rational::Rational(const Rational& y) :num(y.num), den(y.den) {} inline Rational::Rational(const Integer& n) :num(n), den(1) {} inline Rational::Rational(const Integer& n, const Integer& d) :num(n),den(d) { normalize(); } inline Rational::Rational(long n, long d) :num(n), den(d) { normalize(); } inline void Rational::operator = (const Rational& y) { num = y.num; den = y.den; } inline int operator == (const Rational& x, const Rational& y) { return compare(x.num, y.num) == 0 && compare(x.den, y.den) == 0; } inline int operator != (const Rational& x, const Rational& y) { return compare(x.num, y.num) != 0 || compare(x.den, y.den) != 0; } inline int operator < (const Rational& x, const Rational& y) { return compare(x, y) < 0; } inline int operator <= (const Rational& x, const Rational& y) { return compare(x, y) <= 0; } inline int operator > (const Rational& x, const Rational& y) { return compare(x, y) > 0; } inline int operator >= (const Rational& x, const Rational& y) { return compare(x, y) >= 0; } inline int sign(const Rational& x) { return sign(x.num); } inline void Rational::negate() { num.negate(); } #ifdef __GNUG__ inline Rational operator ? (const Rational& x, const Rational& y) { if (compare(x, y) >= 0) return x; else return y; } #endif inline Rational operator + (const Rational& x, const Rational& y) return r { add(x, y, r); } inline Rational operator - (const Rational& x, const Rational& y) return r { sub(x, y, r); } inline Rational operator * (const Rational& x, const Rational& y) return r { mul(x, y, r); } inline Rational operator / (const Rational& x, const Rational& y) return r { div(x, y, r); } inline void Rational::operator += (const Rational& y) { add(*this, y, *this); } inline void Rational::operator -= (const Rational& y) { sub(*this, y, *this); } inline void Rational::operator *= (const Rational& y) { mul(*this, y, *this); } inline void Rational::operator /= (const Rational& y) { div(*this, y, *this); } inline const Integer& Rational::numerator() const { return num; } inline const Integer& Rational::denominator() const { return den; } inline Rational::operator double() const { return ratio(num, den); } //#endif #endif 0707070000020176341004440000020000020000010772040460564766000002400000003651g++-include/SFile.h// 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 _SFile_h #pragma once #define _SFile_h 1 #include class SFile: public File { protected: int sz; // unit size for structured binary IO public: SFile(); SFile(const char* filename, int size, io_mode m, access_mode a); SFile(const char* filename, int size, const char* m); SFile(int filedesc, int size, io_mode m); SFile(FILE* fileptr, int size); ~SFile(); int size(); int setsize(int s); SFile& get(void* x); SFile& put(void* x); SFile& operator[](long i); }; //#ifdef __OPTIMIZE__ inline int SFile::size() { return sz; } inline int SFile::setsize(int s) { int old = sz; sz = s; return old; } inline SFile& SFile::get(void* x) { read(x, sz, 1); return *this; } inline SFile& SFile::put(void* x) { write(x, sz, 1); return *this; } inline SFile& SFile::operator[](long i) { seek(i * sz, 0); return *this; } //#endif #endif 0707070000020176361004440000020000020000011041650460564766200003300000003533g++-include/SampleHistogra// 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) 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 SampleHistogram_h #pragma once #define SampleHistogram_h 1 #include #include "SampleStatistic.h" extern const int SampleHistogramMinimum; extern const int SampleHistogramMaximum; class SampleHistogram : public SampleStatistic { protected: short howManyBuckets; int *bucketCount; double *bucketLimit; public: SampleHistogram(double low, double hi, double bucketWidth = -1.0); ~SampleHistogram(); virtual void reset(); virtual void operator+=(double); int similarSamples(double); inline int buckets() { return(howManyBuckets); }; inline double bucketThreshold(int i) { if (i < 0 || i >= howManyBuckets) error("invalid bucket access"); return(bucketLimit[i]); } inline int inBucket(int i) { if (i < 0 || i >= howManyBuckets) error("invalid bucket access"); return(bucketCount[i]); } void printBuckets(ostream&); }; #endif 0707070000020176371004440000020000020000010505140460564766400003300000003445g++-include/SampleStatisti// 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) 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 SampleStatistic_h #pragma once #define SampleStatistic_h 1 #include class SampleStatistic { protected: int n; double x; double x2; double minValue, maxValue; public : inline SampleStatistic(){ reset();} virtual void reset(); virtual void operator+=(double); inline int samples() {return(n);} double mean(); double stdDev(); double var(); inline double min() {return(minValue);} inline double max() {return(maxValue);} double confidence(int p_percentage); double confidence(double p_value); void error(const char* msg); }; // error handlers extern void default_SampleStatistic_error_handler(const char*); extern one_arg_error_handler_t SampleStatistic_error_handler; extern one_arg_error_handler_t set_SampleStatistic_error_handler(one_arg_error_handler_t f); #endif 0707070000020176401004440000020000020000010244600460564766700002500000103620g++-include/String.h// 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 _String_h #pragma once #define _String_h 1 #include struct StrRep // internal String representations { unsigned short len; // string length unsigned short sz; // allocated space char s[1]; // the string starts here // (at least 1 char for trailing null) // allocated & expanded via non-public fcts }; // primitive ops on StrReps -- nearly all String fns go through these. StrRep* Salloc(StrRep*, const char*, int, int); StrRep* Scopy(StrRep*, StrRep*); StrRep* Sresize(StrRep*, int); StrRep* Scat(StrRep*, const char*, int, const char*, int); StrRep* Scat(StrRep*, const char*, int,const char*,int, const char*,int); StrRep* Sprepend(StrRep*, const char*, int); StrRep* Sreverse(StrRep*, StrRep*); StrRep* Supcase(StrRep*, StrRep*); StrRep* Sdowncase(StrRep*, StrRep*); StrRep* Scapitalize(StrRep*, StrRep*); // These classes need to be defined in the order given class String; class SubString; class Regex; struct re_pattern_buffer; // defined elsewhere struct re_registers; class Regex { private: friend class String; friend class SubString; Regex(const Regex&) {} // no X(X&) void operator = (const Regex&) {} // no assignment protected: re_pattern_buffer* buf; re_registers* reg; void initialize(const char* t, int tlen, int fast, int bufsize, const char* transtable); public: Regex(const char* t, int fast = 0, int bufsize = 40, const char* transtable = 0); Regex(const String& x, int fast = 0, int bufsize = 40, const char* transtable = 0); ~Regex(); int match(const char* s, int len, int pos = 0) const; int search(const char* s, int len, int& matchlen, int startpos = 0) const; int match_info(int& start, int& length, int nth = 0) const; int OK() const; // representation invariant }; class SubString { friend class String; protected: String& S; // The String I'm a substring of unsigned short pos; // starting position in S's rep unsigned short len; // length of substring void assign(StrRep*, const char*, int = -1); SubString(String& x, int p, int l); SubString(const SubString& x); public: // Note there are no public constructors. SubStrings are always // created via String operations ~SubString(); void operator = (const String& y); void operator = (const SubString& y); void operator = (const char* t); void operator = (char c); // return 1 if target appears anywhere in SubString; else 0 int contains(char c) const; int contains(const String& y) const; int contains(const SubString& y) const; int contains(const char* t) const; int contains(const Regex& r) const; // return 1 if target matches entire SubString int matches(const Regex& r) const; // IO friend ostream& operator<<(ostream& s, const SubString& x); // status int length() const; int empty() const; const char* chars() const; int OK() const; }; class String { friend class SubString; friend class Regex; protected: StrRep* rep; // Strings are pointers to their representations // some helper functions int search(int, int, const char*, int = -1) const; int search(int, int, char) const; int match(int, int, int, const char*, int = -1) const; int _gsub(const char*, int, const char* ,int); int _gsub(const Regex&, const char*, int); SubString _substr(int, int); public: // constructors & assignment String(); String(const String& x); String(const SubString& x); String(const char* t); String(const char* t, int len); String(char c); ~String(); void operator = (const String& y); void operator = (const char* y); void operator = (char c); void operator = (const SubString& y); // concatenation void operator += (const String& y); void operator += (const SubString& y); void operator += (const char* t); void operator += (char c); void prepend(const String& y); void prepend(const SubString& y); void prepend(const char* t); void prepend(char c); // See below for inline declarations of constructive versions, like // String operator + (const String& x, const String& y); // procedural versions: // concatenate first 2 args, store result in last arg friend void cat(const String&, const String&, String&); friend void cat(const String&, const SubString&, String&); friend void cat(const String&, const char*, String&); friend void cat(const String&, char, String&); friend void cat(const SubString&, const String&, String&); friend void cat(const SubString&, const SubString&, String&); friend void cat(const SubString&, const char*, String&); friend void cat(const SubString&, char, String&); friend void cat(const char*, const String&, String&); friend void cat(const char*, const SubString&, String&); friend void cat(const char*, const char*, String&); friend void cat(const char*, char, String&); // double concatenation, by request. (yes, there are too many versions, // but if one is supported, then the others should be too...) // Concatenate first 3 args, store in last arg friend void cat(const String&,const String&, const String&,String&); friend void cat(const String&,const String&,const SubString&,String&); friend void cat(const String&,const String&, const char*, String&); friend void cat(const String&,const String&, char, String&); friend void cat(const String&,const SubString&,const String&,String&); friend void cat(const String&,const SubString&,const SubString&,String&); friend void cat(const String&,const SubString&, const char*, String&); friend void cat(const String&,const SubString&, char, String&); friend void cat(const String&,const char*, const String&, String&); friend void cat(const String&,const char*, const SubString&, String&); friend void cat(const String&,const char*, const char*, String&); friend void cat(const String&,const char*, char, String&); friend void cat(const char*, const String&, const String&,String&); friend void cat(const char*,const String&,const SubString&,String&); friend void cat(const char*,const String&, const char*, String&); friend void cat(const char*,const String&, char, String&); friend void cat(const char*,const SubString&,const String&,String&); friend void cat(const char*,const SubString&,const SubString&,String&); friend void cat(const char*,const SubString&, const char*, String&); friend void cat(const char*,const SubString&, char, String&); friend void cat(const char*,const char*, const String&, String&); friend void cat(const char*,const char*, const SubString&, String&); friend void cat(const char*,const char*, const char*, String&); friend void cat(const char*,const char*, char, String&); // searching & matching // return position of target in string or -1 for failure int index(char c, int startpos = 0) const; int index(const String& y, int startpos = 0) const; int index(const SubString& y, int startpos = 0) const; int index(const char* t, int startpos = 0) const; int index(const Regex& r, int startpos = 0) const; // return 1 if target appears anyhere in String; else 0 int contains(char c) const; int contains(const String& y) const; int contains(const SubString& y) const; int contains(const char* t) const; int contains(const Regex& r) const; // return 1 if target appears anywhere after position pos // (or before, if pos is negative) in String; else 0 int contains(char c, int pos) const; int contains(const String& y, int pos) const; int contains(const SubString& y, int pos) const; int contains(const char* t, int pos) const; int contains(const Regex& r, int pos) const; // return 1 if target appears at position pos in String; else 0 int matches(char c, int pos = 0) const; int matches(const String& y, int pos = 0) const; int matches(const SubString& y, int pos = 0) const; int matches(const char* t, int pos = 0) const; int matches(const Regex& r, int pos = 0) const; // return number of occurences of target in String int freq(char c) const; int freq(const String& y) const; int freq(const SubString& y) const; int freq(const char* t) const; // SubString extraction // Note that you can't take a substring of a const String, since // this leaves open the possiblility of indirectly modifying the // String through the SubString SubString at(int pos, int len); SubString at(const String& x, int startpos = 0); SubString at(const SubString& x, int startpos = 0); SubString at(const char* t, int startpos = 0); SubString at(char c, int startpos = 0); SubString at(const Regex& r, int startpos = 0); SubString before(int pos); SubString before(const String& x, int startpos = 0); SubString before(const SubString& x, int startpos = 0); SubString before(const char* t, int startpos = 0); SubString before(char c, int startpos = 0); SubString before(const Regex& r, int startpos = 0); SubString through(int pos); SubString through(const String& x, int startpos = 0); SubString through(const SubString& x, int startpos = 0); SubString through(const char* t, int startpos = 0); SubString through(char c, int startpos = 0); SubString through(const Regex& r, int startpos = 0); SubString from(int pos); SubString from(const String& x, int startpos = 0); SubString from(const SubString& x, int startpos = 0); SubString from(const char* t, int startpos = 0); SubString from(char c, int startpos = 0); SubString from(const Regex& r, int startpos = 0); SubString after(int pos); SubString after(const String& x, int startpos = 0); SubString after(const SubString& x, int startpos = 0); SubString after(const char* t, int startpos = 0); SubString after(char c, int startpos = 0); SubString after(const Regex& r, int startpos = 0); // deletion // delete len chars starting at pos void del(int pos, int len); // delete the first occurrence of target after startpos void del(const String& y, int startpos = 0); void del(const SubString& y, int startpos = 0); void del(const char* t, int startpos = 0); void del(char c, int startpos = 0); void del(const Regex& r, int startpos = 0); // global substitution: substitute all occurrences of pat with repl int gsub(const String& pat, const String& repl); int gsub(const SubString& pat, const String& repl); int gsub(const char* pat, const String& repl); int gsub(const char* pat, const char* repl); int gsub(const Regex& pat, const String& repl); // friends & utilities // split string into array res at separators; return number of elements friend int split(const String& x, String res[], int maxn, const String& sep); friend int split(const String& x, String res[], int maxn, const Regex& sep); friend String common_prefix(const String& x, const String& y, int startpos = 0); friend String common_suffix(const String& x, const String& y, int startpos = -1); friend String replicate(char c, int n); friend String replicate(const String& y, int n); friend String join(String src[], int n, const String& sep); // simple builtin transformations friend String reverse(const String& x); friend String upcase(const String& x); friend String downcase(const String& x); friend String capitalize(const String& x); // in-place versions of above void reverse(); void upcase(); void downcase(); void capitalize(); // element extraction char& operator [] (int i); char elem(int i) const; char firstchar() const; char lastchar() const; // conversion operator const char*() const; const char* chars() const; // IO friend ostream& operator<<(ostream& s, const String& x); friend ostream& operator<<(ostream& s, const SubString& x); friend istream& operator>>(istream& s, String& x); friend int readline(istream& s, String& x, char terminator = '\n', int discard_terminator = 1); // status int length() const; int empty() const; // preallocate some space for String void alloc(int newsize); // report current allocation (not length!) int allocation() const; volatile void error(const char* msg) const; int OK() const; }; typedef String StrTmp; // for backward compatibility // other externs int compare(const String& x, const String& y); int compare(const String& x, const SubString& y); int compare(const String& x, const char* y); int compare(const SubString& x, const String& y); int compare(const SubString& x, const SubString& y); int compare(const SubString& x, const char* y); int fcompare(const String& x, const String& y); // ignore case // some built in regular expressions extern const Regex RXwhite; // = "[ \n\t\r\v\f]+" extern const Regex RXint; // = "-?[0-9]+" extern const Regex RXdouble; // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\| // \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\) // \\([eE][---+]?[0-9]+\\)?" extern const Regex RXalpha; // = "[A-Za-z]+" extern const Regex RXlowercase; // = "[a-z]+" extern const Regex RXuppercase; // = "[A-Z]+" extern const Regex RXalphanum; // = "[0-9A-Za-z]+" extern const Regex RXidentifier; // = "[A-Za-z_][A-Za-z0-9_]*" //#ifdef __OPTIMIZE__ extern StrRep _nilStrRep; extern String _nilString; // status reports, needed before defining other things inline int String::length() const { return rep->len; } inline int String::empty() const { return rep->len == 0; } inline const char* String::chars() const { return &(rep->s[0]); } inline int String::allocation() const { return rep->sz; } inline void String::alloc(int newsize) { rep = Sresize(rep, newsize); } inline int SubString::length() const { return len; } inline int SubString::empty() const { return len == 0; } inline const char* SubString::chars() const { return &(S.rep->s[pos]); } // constructors inline String::String() : rep(&_nilStrRep) {} inline String::String(const String& x) : rep(Scopy(0, x.rep)) {} inline String::String(const char* t) : rep(Salloc(0, t, -1, -1)) {} inline String::String(const char* t, int tlen) : rep(Salloc(0, t, tlen, tlen)) {} inline String::String(const SubString& y) : rep(Salloc(0, y.chars(), y.length(), y.length())) {} inline String::String(char c) : rep(Salloc(0, &c, 1, 1)) {} inline String::~String() { if (rep != &_nilStrRep) delete rep; } inline SubString::SubString(const SubString& x) :S(x.S), pos(x.pos), len(x.len) {} inline SubString::SubString(String& x, int first, int l) :S(x), pos(first), len(l) {} inline SubString::~SubString() {} // assignment inline void String::operator = (const String& y) { rep = Scopy(rep, y.rep); } inline void String::operator=(const char* t) { rep = Salloc(rep, t, -1, -1); } inline void String::operator=(const SubString& y) { rep = Salloc(rep, y.chars(), y.length(), y.length()); } inline void String::operator=(char c) { rep = Salloc(rep, &c, 1, 1); } inline void SubString::operator = (const char* ys) { assign(0, ys); } inline void SubString::operator = (char ch) { assign(0, &ch, 1); } inline void SubString::operator = (const String& y) { assign(y.rep, y.chars(), y.length()); } inline void SubString::operator = (const SubString& y) { assign(y.S.rep, y.chars(), y.length()); } // Zillions of cats... inline void cat(const String& x, const String& y, String& r) { r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); } inline void cat(const String& x, const SubString& y, String& r) { r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); } inline void cat(const String& x, const char* y, String& r) { r.rep = Scat(r.rep, x.chars(), x.length(), y, -1); } inline void cat(const String& x, char y, String& r) { r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1); } inline void cat(const SubString& x, const String& y, String& r) { r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); } inline void cat(const SubString& x, const SubString& y, String& r) { r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length()); } inline void cat(const SubString& x, const char* y, String& r) { r.rep = Scat(r.rep, x.chars(), x.length(), y, -1); } inline void cat(const SubString& x, char y, String& r) { r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1); } inline void cat(const char* x, const String& y, String& r) { r.rep = Scat(r.rep, x, -1, y.chars(), y.length()); } inline void cat(const char* x, const SubString& y, String& r) { r.rep = Scat(r.rep, x, -1, y.chars(), y.length()); } inline void cat(const char* x, const char* y, String& r) { r.rep = Scat(r.rep, x, -1, y, -1); } inline void cat(const char* x, char y, String& r) { r.rep = Scat(r.rep, x, -1, &y, 1); } inline void cat(const String& a, const String& x, const String& y, String& r) { r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); } inline void cat(const String& a, const String& x, const SubString& y, String& r) { r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); } inline void cat(const String& a, const String& x, const char* y, String& r) { r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1); } inline void cat(const String& a, const String& x, char y, String& r) { r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1); } inline void cat(const String& a, const SubString& x, const String& y, String& r) { r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); } inline void cat(const String& a, const SubString& x, const SubString& y, String& r) { r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length()); } inline void cat(const String& a, const SubString& x, const char* y, String& r) { r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1); } inline void cat(const String& a, const SubString& x, char y, String& r) { r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1); } inline void cat(const String& a, const char* x, const String& y, String& r) { r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length()); } inline void cat(const String& a, const char* x, const SubString& y, String& r) { r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length()); } inline void cat(const String& a, const char* x, const char* y, String& r) { r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y, -1); } inline void cat(const String& a, const char* x, char y, String& r) { r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, &y, 1); } inline void cat(const char* a, const String& x, const String& y, String& r) { r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); } inline void cat(const char* a, const String& x, const SubString& y, String& r) { r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); } inline void cat(const char* a, const String& x, const char* y, String& r) { r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1); } inline void cat(const char* a, const String& x, char y, String& r) { r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1); } inline void cat(const char* a, const SubString& x, const String& y, String& r) { r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); } inline void cat(const char* a, const SubString& x, const SubString& y, String& r) { r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length()); } inline void cat(const char* a, const SubString& x, const char* y, String& r) { r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1); } inline void cat(const char* a, const SubString& x, char y, String& r) { r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1); } inline void cat(const char* a, const char* x, const String& y, String& r) { r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length()); } inline void cat(const char* a, const char* x, const SubString& y, String& r) { r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length()); } inline void cat(const char* a, const char* x, const char* y, String& r) { r.rep = Scat(r.rep, a, -1, x, -1, y, -1); } inline void cat(const char* a, const char* x, char y, String& r) { r.rep = Scat(r.rep, a, -1, x, -1, &y, 1); } // operator versions inline void String::operator +=(const String& y) { cat(*this, y, *this); } inline void String::operator +=(const SubString& y) { cat(*this, y, *this); } inline void String::operator += (const char* y) { cat(*this, y, *this); } inline void String:: operator +=(char y) { cat(*this, y, *this); } // constructive concatenation inline String operator + (const String& x, const String& y) return r; { cat(x, y, r); } inline String operator + (const String& x, const SubString& y) return r; { cat(x, y, r); } inline String operator + (const String& x, const char* y) return r; { cat(x, y, r); } inline String operator + (const String& x, char y) return r; { cat(x, y, r); } inline String operator + (const SubString& x, const String& y) return r; { cat(x, y, r); } inline String operator + (const SubString& x, const SubString& y) return r; { cat(x, y, r); } inline String operator + (const SubString& x, const char* y) return r; { cat(x, y, r); } inline String operator + (const SubString& x, char y) return r; { cat(x, y, r); } inline String operator + (const char* x, const String& y) return r; { cat(x, y, r); } inline String operator + (const char* x, const SubString& y) return r; { cat(x, y, r); } // prepend inline void String::prepend(const String& y) { rep = Sprepend(rep, y.chars(), y.length()); } inline void String::prepend(const char* y) { rep = Sprepend(rep, y, -1); } inline void String::prepend(char y) { rep = Sprepend(rep, &y, 1); } inline void String::prepend(const SubString& y) { rep = Sprepend(rep, y.chars(), y.length()); } // misc transformations inline String reverse(const String& x) return r; { r.rep = Sreverse(x.rep, r.rep); } inline void String::reverse() { rep = Sreverse(rep, rep); } inline String upcase(const String& x) return r; { r.rep = Supcase(x.rep, r.rep); } inline void String::upcase() { rep = Supcase(rep, rep); } inline String downcase(const String& x) return r; { r.rep = Sdowncase(x.rep, r.rep); } inline void String::downcase() { rep = Sdowncase(rep, rep); } inline String capitalize(const String& x) return r; { r.rep = Scapitalize(x.rep, r.rep); } inline void String::capitalize() { rep = Scapitalize(rep, rep); } // element extraction inline char& String::operator [] (int i) { if (((unsigned)i) >= length()) error("invalid index"); return rep->s[i]; } inline char String::elem (int i) const { if (((unsigned)i) >= length()) error("invalid index"); return rep->s[i]; } inline char String::firstchar() const { return elem(0); } inline char String::lastchar() const { return elem(length() - 1); } // searching inline int String::index(char c, int startpos) const { return search(startpos, length(), c); } inline int String::index(const char* t, int startpos) const { return search(startpos, length(), t); } inline int String::index(const String& y, int startpos) const { return search(startpos, length(), y.chars(), y.length()); } inline int String::index(const SubString& y, int startpos) const { return search(startpos, length(), y.chars(), y.length()); } inline int String::index(const Regex& r, int startpos) const { int unused; return r.search(chars(), length(), unused, startpos); } inline int String::contains(char c) const { return search(0, length(), c) >= 0; } inline int String::contains(const char* t) const { return search(0, length(), t) >= 0; } inline int String::contains(const String& y) const { return search(0, length(), y.chars(), y.length()) >= 0; } inline int String::contains(const SubString& y) const { return search(0, length(), y.chars(), y.length()) >= 0; } inline int String::contains(char c, int p) const { return match(p, length(), 0, &c, 1) >= 0; } inline int String::contains(const char* t, int p) const { return match(p, length(), 0, t) >= 0; } inline int String::contains(const String& y, int p) const { return match(p, length(), 0, y.chars(), y.length()) >= 0; } inline int String::contains(const SubString& y, int p) const { return match(p, length(), 0, y.chars(), y.length()) >= 0; } inline int String::contains(const Regex& r) const { int unused; return r.search(chars(), length(), unused, 0) >= 0; } inline int String::contains(const Regex& r, int p) const { return r.match(chars(), length(), p) >= 0; } inline int String::matches(const SubString& y, int p) const { return match(p, length(), 1, y.chars(), y.length()) >= 0; } inline int String::matches(const String& y, int p) const { return match(p, length(), 1, y.chars(), y.length()) >= 0; } inline int String::matches(const char* t, int p) const { return match(p, length(), 1, t) >= 0; } inline int String::matches(char c, int p) const { return match(p, length(), 1, &c, 1) >= 0; } inline int String::matches(const Regex& r, int p) const { int l = (p < 0)? -p : length() - p; return r.match(chars(), length(), p) == l; } inline int SubString::contains(const char* t) const { return S.search(pos, pos+len, t) >= 0; } inline int SubString::contains(const String& y) const { return S.search(pos, pos+len, y.chars(), y.length()) >= 0; } inline int SubString::contains(const SubString& y) const { return S.search(pos, pos+len, y.chars(), y.length()) >= 0; } inline int SubString::contains(char c) const { return S.search(pos, pos+len, 0, c) >= 0; } inline int SubString::contains(const Regex& r) const { int unused; return r.search(chars(), len, unused, 0) >= 0; } inline int SubString::matches(const Regex& r) const { return r.match(chars(), len, 0) == len; } inline int String::gsub(const String& pat, const String& r) { return _gsub(pat.chars(), pat.length(), r.chars(), r.length()); } inline int String::gsub(const SubString& pat, const String& r) { return _gsub(pat.chars(), pat.length(), r.chars(), r.length()); } inline int String::gsub(const Regex& pat, const String& r) { return _gsub(pat, r.chars(), r.length()); } inline int String::gsub(const char* pat, const String& r) { return _gsub(pat, -1, r.chars(), r.length()); } inline int String::gsub(const char* pat, const char* r) { return _gsub(pat, -1, r, -1); } inline String::operator const char*() const { return str(chars()); } inline ostream& operator<<(ostream& s, const String& x) { s.put(x.chars()); return s; } // a zillion comparison operators inline int operator==(const String& x, const String& y) { return compare(x, y) == 0; } inline int operator!=(const String& x, const String& y) { return compare(x, y) != 0; } inline int operator>(const String& x, const String& y) { return compare(x, y) > 0; } inline int operator>=(const String& x, const String& y) { return compare(x, y) >= 0; } inline int operator<(const String& x, const String& y) { return compare(x, y) < 0; } inline int operator<=(const String& x, const String& y) { return compare(x, y) <= 0; } inline int operator==(const String& x, const SubString& y) { return compare(x, y) == 0; } inline int operator!=(const String& x, const SubString& y) { return compare(x, y) != 0; } inline int operator>(const String& x, const SubString& y) { return compare(x, y) > 0; } inline int operator>=(const String& x, const SubString& y) { return compare(x, y) >= 0; } inline int operator<(const String& x, const SubString& y) { return compare(x, y) < 0; } inline int operator<=(const String& x, const SubString& y) { return compare(x, y) <= 0; } inline int operator==(const String& x, const char* t) { return compare(x, t) == 0; } inline int operator!=(const String& x, const char* t) { return compare(x, t) != 0; } inline int operator>(const String& x, const char* t) { return compare(x, t) > 0; } inline int operator>=(const String& x, const char* t) { return compare(x, t) >= 0; } inline int operator<(const String& x, const char* t) { return compare(x, t) < 0; } inline int operator<=(const String& x, const char* t) { return compare(x, t) <= 0; } inline int operator==(const SubString& x, const String& y) { return compare(y, x) == 0; } inline int operator!=(const SubString& x, const String& y) { return compare(y, x) != 0; } inline int operator>(const SubString& x, const String& y) { return compare(y, x) < 0; } inline int operator>=(const SubString& x, const String& y) { return compare(y, x) <= 0; } inline int operator<(const SubString& x, const String& y) { return compare(y, x) > 0; } inline int operator<=(const SubString& x, const String& y) { return compare(y, x) >= 0; } inline int operator==(const SubString& x, const SubString& y) { return compare(x, y) == 0; } inline int operator!=(const SubString& x, const SubString& y) { return compare(x, y) != 0; } inline int operator>(const SubString& x, const SubString& y) { return compare(x, y) > 0; } inline int operator>=(const SubString& x, const SubString& y) { return compare(x, y) >= 0; } inline int operator<(const SubString& x, const SubString& y) { return compare(x, y) < 0; } inline int operator<=(const SubString& x, const SubString& y) { return compare(x, y) <= 0; } inline int operator==(const SubString& x, const char* t) { return compare(x, t) == 0; } inline int operator!=(const SubString& x, const char* t) { return compare(x, t) != 0; } inline int operator>(const SubString& x, const char* t) { return compare(x, t) > 0; } inline int operator>=(const SubString& x, const char* t) { return compare(x, t) >= 0; } inline int operator<(const SubString& x, const char* t) { return compare(x, t) < 0; } inline int operator<=(const SubString& x, const char* t) { return compare(x, t) <= 0; } inline Regex::Regex(const String& x, int fast, int bufsize, const char* transtable) { initialize(x.chars(), x.length(), fast, bufsize, transtable); } inline Regex::Regex(const char* t, int fast, int bufsize, const char* transtable) { initialize(t, -1, fast, bufsize, transtable); } // a helper needed by at, before, etc. inline SubString String::_substr(int first, int l) { if (first < 0 || (unsigned)(first + l) > length()) return SubString(_nilString, 0, 0) ; else return SubString(*this, first, l); } //#endif #endif 0707070000020176411004440000020000020000011660140460564767100002600000003477g++-include/Uniform.h// 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) 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 _Uniform_h #pragma once #define _Uniform_h 1 #include // // The interval [lo..hi] // class Uniform: public Random { double pLow; double pHigh; double delta; public: Uniform(double low, double high, RNG *gen); double low(); double low(double x); double high(); double high(double x); virtual double operator()(); }; //#ifdef __OPTIMIZE__ inline Uniform::Uniform(double low, double high, RNG *gen):(gen) { pLow = (low < high) ? low : high; pHigh = (low < high) ? high : low; delta = pHigh - pLow; } inline double Uniform::low() { return pLow; } inline double Uniform::low(double x) { double tmp = pLow; pLow = x; delta = pHigh - pLow; return tmp; } inline double Uniform::high() { return pHigh; } inline double Uniform::high(double x) { double tmp = pHigh; pHigh = x; delta = pHigh - pLow; return tmp; } //#endif #endif 0707070000020176421004440000020000020000010050520460564767300002600000003514g++-include/Weibull.h// 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) 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 _Weibull_h #pragma once #define _Weibull_h #include class Weibull: public Random { protected: double pAlpha; double pInvAlpha; double pBeta; void setState(); public: Weibull(double alpha, double beta, RNG *gen); double alpha(); double alpha(double x); double beta(); double beta(double x); virtual double operator()(); }; //#ifdef __OPTIMIZE__ inline void Weibull::setState() { pInvAlpha = 1.0 / pAlpha; } inline Weibull::Weibull(double alpha, double beta, RNG *gen) : (gen) { pAlpha = alpha; pBeta = beta; setState(); } inline double Weibull::alpha() { return pAlpha; } inline double Weibull::alpha(double x) { double tmp = pAlpha; pAlpha = x; setState(); return tmp; } inline double Weibull::beta() { return pBeta; }; inline double Weibull::beta(double x) { double tmp = pBeta; pBeta = x; return tmp; }; //#endif #endif 0707070000020176431004440000020000020000010335170460564767500002500000003017g++-include/assert.h// This may look like C code, but it is really -*- C++ -*- /* Copyright (C) 1988 Free Software Foundation 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. */ /* Allow this file to be included multiple times with different settings of NDEBUG. */ #undef assert #undef assertval #ifdef NDEBUG #define assert(ignore) #define assertval(ex) (ex) #else extern "C" void __eprintf (char*, int, char*); /* Defined in gnulib */ extern "C" volatile void abort(); #define assert(ex) \ ((ex) ? 1 : \ (__eprintf("Failed assertion " #ex " at line %d of `%s'.\n", \ __LINE__, __FILE__), abort (), 0)) #define assertval(ex) \ ((ex) ? 1 : \ (__eprintf("Failed assertion " #ex " at line %d of `%s'.\n", \ __LINE__, __FILE__), abort (), 0)) #endif NDEBUG 0707070000020176441004440000020000020000010653360460564767700002600000007030g++-include/builtin.h// 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. */ /* arithmetic, etc. functions on built in types */ #ifndef _builtin_h #pragma once #define _builtin_h 1 typedef void (*one_arg_error_handler_t)(const char*); typedef void (*two_arg_error_handler_t)(const char*, const char*); #include #include #include long gcd(long, long); long lg(unsigned long); double pow(double, long); long pow(long, long); double start_timer(); double return_elapsed_time(double last_time = 0.0); char* itoa(long x, int base = 10, int width = 0); char* itoa(unsigned long x, int base = 10, int width = 0); #ifdef __GNUG__ char* itoa(long long x, int base = 10, int width = 0); char* itoa(unsigned long long x, int base = 10, int width = 0); #endif char* dtoa(double x, char cvt = 'g', int width = 0, int prec = 6); char* hex(long x, int width = 0); char* hex(unsigned long x, int width = 0); char* oct(long x, int width = 0); char* oct(unsigned long x, int width = 0); char* dec(long x, int width = 0); char* dec(unsigned long x, int width = 0); char* form(const char* fmt ...); char* chr(char ch, int width = 0); char* str(const char* s, int width = 0); unsigned int hashpjw(const char*); unsigned int multiplicativehash(int); unsigned int foldhash(double); extern void default_one_arg_error_handler(const char*); extern void default_two_arg_error_handler(const char*, const char*); extern two_arg_error_handler_t lib_error_handler; extern two_arg_error_handler_t set_lib_error_handler(two_arg_error_handler_t f); //#ifdef __OPTIMIZE__ static inline double abs(double arg) { return (arg < 0.0)? -arg : arg; } static inline float abs(float arg) { return (arg < 0.0)? -arg : arg; } static inline short abs(short arg) { return (arg < 0)? -arg : arg; } static inline long abs(long arg) { return (arg < 0)? -arg : arg; } static inline int sign(long arg) { return (arg == 0) ? 0 : ( (arg > 0) ? 1 : -1 ); } static inline int sign(double arg) { return (arg == 0.0) ? 0 : ( (arg > 0.0) ? 1 : -1 ); } static inline long sqr(long arg) { return arg * arg; } static inline double sqr(double arg) { return arg * arg; } static inline int even(long arg) { return !(arg & 1); } static inline int odd(long arg) { return (arg & 1); } static inline long lcm(long x, long y) { return x / gcd(x, y) * y; } static inline void setbit(long& x, long b) { x |= (1 << b); } static inline void clearbit(long& x, long b) { x &= ~(1 << b); } static inline int testbit(long x, long b) { return ((x & (1 << b)) != 0); } //#endif #endif 0707070000020176451004440000020000020000011103110460564770100002600000003352g++-include/compare.h// 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 _compare_h #pragma once #define _compare_h 1 #include inline int compare(int a, int b) { return a - b; } inline int compare(short a, short b) { return a - b; } inline int compare(char a, char b) { return a - b; } inline int compare(unsigned long a, unsigned long b) { return (a < b)? -1 : (a > b)? 1 : 0; } inline int compare(unsigned int a, unsigned int b) { return (a < b)? -1 : (a > b)? 1 : 0; } inline int compare(unsigned short a, unsigned short b) { return (a < b)? -1 : (a > b)? 1 : 0; } inline int compare(unsigned char a, unsigned char b) { return (a < b)? -1 : (a > b)? 1 : 0; } inline int compare(float a, float b) { return a - b; } inline int compare(double a, double b) { return a - b; } inline int compare(const char* a, const char* b) { return strcmp(a,b); } #endif 0707070000020176461004440000020000020000011002630460564770300002400000003624g++-include/ctype.h// Here's a ctype.h for SunOS-3 and vax 4.3BSD. // It will probably work on most BSD derived systems. // Just compare it to the C version to verify. // No big deal, but it will save you some typing. #ifndef _ctype_h #pragma once #define _ctype_h #include /* sorry, but needed for USG stuff */ static const int _U = 01; static const int _L = 02; static const int _N = 04; static const int _S = 010; static const int _P = 020; static const int _C = 040; #if defined(USG) || defined(DGUX) static const int _B = 0100; /* different from BSD */ static const int _X = 0200; /* different from BSD */ #else static const int _X = 0100; static const int _B = 0200; #endif #ifdef DGUX #define CTYPE_TYPE short #else #define CTYPE_TYPE char #endif #if defined(DGUX) || defined(USG) || defined(hpux) #define _ctype_ _ctype #endif extern "C" { extern CTYPE_TYPE _ctype_[]; } inline int isalpha(char c) { return ((_ctype_+1)[c]&(_U|_L)); } inline int isupper(char c) { return ((_ctype_+1)[c]&_U); } inline int islower(char c) { return ((_ctype_+1)[c]&_L); } inline int isdigit(char c) { return ((_ctype_+1)[c]&_N); } inline int isxdigit(char c) { return ((_ctype_+1)[c]&_X); } inline int isspace(char c) { return ((_ctype_+1)[c]&_S); } inline int ispunct(char c) { return ((_ctype_+1)[c]&_P); } inline int isalnum(char c) { return ((_ctype_+1)[c]&(_U|_L|_N)); } inline int isprint(char c) { return ((_ctype_+1)[c]&(_P|_U|_L|_N|_B)); } inline int isgraph(char c) { return ((_ctype_+1)[c]&(_P|_U|_L|_N)); } inline int iscntrl(char c) { return ((_ctype_+1)[c]&_C); } inline int isascii(char c) { return ((unsigned)(c)<=0177); } inline int toupper(char c) { return islower(c)? (c-'a'+'A') : c; } inline int tolower(char c) { return isupper(c)? (c-'A'+'a') : c; } inline int toascii(char c) { return ((c)&0177); } #ifdef _ctype_ #undef _ctype_ #endif #ifdef CTYPE_TYPE #undef CTYPE_TYPE #endif #endif _ctype_h 0707070000020176471004440000020000020000010443000460564770500002600000003476g++-include/generic.h// 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 generic_h #pragma once #define generic_h 1 /* * See the CPP manual, argument prescan section for explanation */ #define name2(a,b) gEnErIc2(a,b) #define gEnErIc2(a,b) a ## b #define name3(a,b,c) gEnErIc3(a,b,c) #define gEnErIc3(a,b,c) a ## b ## c #define name4(a,b,c,d) gEnErIc4(a,b,c,d) #define gEnErIc4(a,b,c,d) a ## b ## c ## d #define GENERIC_STRING(a) gEnErIcStRiNg(a) #define gEnErIcStRiNg(a) #a #define declare(clas,t) name2(clas,declare)(t) #define declare2(clas,t1,t2) name2(clas,declare2)(t1,t2) #define implement(clas,t) name2(clas,implement)(t) #define implement2(clas,t1,t2) name2(clas,implement2)(t1,t2) extern genericerror(int,char*); typedef int (*GPT)(int,char*); #define set_handler(gen,type,x) name4(set_,type,gen,_handler)(x) #define errorhandler(gen,type) name3(type,gen,handler) #define callerror(gen,type,a,b) (*errorhandler(gen,type))(a,b) #endif generic_h 0707070000020176501004440000020000020000011441270460564770700002300000000071g++-include/libc.h#ifndef _File_h #pragma once #include #endif 0707070000020176531004440000020000020000011154020460564771100002300000011446g++-include/math.h// 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 _math_h #pragma once #define _math_h 1 #if defined(hp300) && defined(__HAVE_FPU__) #define __HAVE_68881__ 1 #endif #ifdef __HAVE_68881__ /* MC68881/2 Floating-Point Coprocessor */ #include extern "C" { /* fill in what we've left out */ double acosh(double); double asinh(double); double cbrt(double); double copysign(double,double); double erf(double); double erfc(double); double finite(double); double gamma(double); double hypot(double,double); double infnan(int); int isinf(double); int isnan(double); double j0(double); double j1(double); double jn(int, double); double lgamma(double); double y0(double); double y1(double); double yn(int, double); double aint(double); double anint(double); int irint(double); int nint(double); } /* Please add inline asm code for other machines here! */ #else extern "C" { double acos(double); double acosh(double); double asin(double); double asinh(double); double atan(double); double atan2(double, double); double atanh(double); double cbrt(double); double ceil(double); double copysign(double,double); double cos(double); double cosh(double); double drem(double,double); double erf(double); double erfc(double); double exp(double); double expm1(double); double fabs(double); double finite(double); double floor(double); double frexp(double, int*); double gamma(double); double hypot(double,double); double infnan(int); #if !defined(sequent) && !defined(DGUX) /* see below */ int isinf(double); int isnan(double); #endif double j0(double); double j1(double); double jn(int, double); double ldexp(double, int); double lgamma(double); double log(double); double log10(double); double log1p(double); double logb(double); double modf(double, double*); double pow(double, double); double rint(double); double scalb(double, int); double sin(double); double sinh(double); double sqrt(double); double tan(double); double tanh(double); double y0(double); double y1(double); double yn(int, double); double aint(double); double anint(double); int irint(double); int nint(double); } #endif /* libg++ doesn't use this since it is not available on some systems */ /* the following ifdef is just for compiling OOPS */ #ifndef DONT_DECLARE_EXCEPTION struct libm_exception { int type; char* name; double arg1, arg2, retval; }; #define DOMAIN 1 #define SING 2 #define OVERFLOW 3 #define UNDERFLOW 4 #define TLOSS 5 #define PLOSS 6 extern "C" int matherr(libm_exception*); #endif #include /* On some systems, HUGE ought to be MAXFLOAT or IEEE infinity */ #ifndef HUGE #define HUGE MAXDOUBLE #endif /* sequents don't supply these. The following should suffice */ #if defined(sequent) || defined(DGUX) static inline int isnan(double x) { return x != x; } static inline int isinf(double x) { return x > MAXDOUBLE || x < -MAXDOUBLE; } #endif /* These seem to be sun & sysV names of these constants */ #ifndef M_E #define M_E 2.7182818284590452354 #endif #ifndef M_LOG2E #define M_LOG2E 1.4426950408889634074 #endif #ifndef M_LOG10E #define M_LOG10E 0.43429448190325182765 #endif #ifndef M_LN2 #define M_LN2 0.69314718055994530942 #endif #ifndef M_LN10 #define M_LN10 2.30258509299404568402 #endif #ifndef M_PI #define M_PI 3.14159265358979323846 #endif #ifndef M_PI_2 #define M_PI_2 1.57079632679489661923 #endif #ifndef M_1_PI #define M_1_PI 0.31830988618379067154 #endif #ifndef M_PI_4 #define M_PI_4 0.78539816339744830962 #endif #ifndef M_2_PI #define M_2_PI 0.63661977236758134308 #endif #ifndef M_2_SQRTPI #define M_2_SQRTPI 1.12837916709551257390 #endif #ifndef M_SQRT2 #define M_SQRT2 1.41421356237309504880 #endif #ifndef M_SQRT1_2 #define M_SQRT1_2 0.70710678118654752440 #endif #ifndef PI // as in stroustrup #define PI M_PI #endif #ifndef PI2 #define PI2 M_PI_2 #endif #endif 0707070000020176541004440000020000020000010502240460564771300002400000000144g++-include/osfcn.h#pragma once #include #include #include #include 0707070000020176551004440000020000020000010116640460564771500002400000015734g++-include/List.hP// 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 #pragma once #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; 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; } 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(); }; 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& List::operator = (List& a) { reference(a.P); dereference(P); P = a.P; return *this; } inline & List::get() { return P->hd; } inline & List::head() { return P->hd; } inline List List::tail() { reference(P->tl); return List(P->tl); } inline void List::set_tail(List& a) { reference(a.P); dereference(P->tl); P->tl = a.P; } 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 List List::nth(int n) { for (ListNode* p = P; n-- > 0; p = p->tl); reference(p); return List(p); } inline & List::operator [] (int n) { for (ListNode* p = P; n-- > 0; p = p->tl); return (p->hd); } inline List List::last() { ListNode* p = P; if (p != &NilListNode) while (p->tl != &NilListNode) p = p->tl; reference(p); return List(p); } inline void List::push( head) { ListNode* oldp = P; P = newListNode(head, oldp); } inline List::pop() { res = P->hd; reference(P->tl); dereference(P); P = P->tl; return res; } inline void List::append(List& l) { ListNode* p = P; ListNode* a = l.P; reference(a); if (p != &NilListNode) { while (p->tl != &NilListNode) p = p->tl; p->tl = a; } else P = a; } inline int List::length() { int l = 0; for (ListNode* p = P; p != &NilListNode; p = p->tl) ++l; return l; } 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 0707070000020176561004440000020000020000011032430460564771700002500000000452g++-include/setjmp.h#ifndef _setjmp_h #pragma once extern "C" { #define setjmp C_header_setjmp #define longjmp C_header_longjmp #include "/usr/include/setjmp.h" #undef setjmp #undef longjmp #ifndef _setjmp_h #define _setjmp_h 1 #endif extern int setjmp(jmp_buf); extern void longjmp(jmp_buf, int); } #endif 0707070000020176571004440000020000020000010472630460564772200002200000020103g++-include/std.h// 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 _std_h #pragma once #define _std_h 1 #include /* sorry, but needed for DGUX folks... */ #include /* sorry, but needed for USG folks... */ extern "C" { void volatile _exit(int); void volatile abort(void); int abs(int); int access(const char*, int); int acct(const char*); unsigned alarm(unsigned); double atof(const char*); int atoi(const char*); long atol(const char*); int bind(int, void*, int); int brk(void*); int bsearch (const void *, const void *, unsigned long, unsigned long, auto int (*ptf)(const void*, const void*)); void* calloc(unsigned, unsigned); void cfree(void*); int chdir(const char*); int chmod(const char*, int); int chown(const char*, int, int); long clock(void); int close(int); #ifdef DGUX int creat(char*, unsigned long int); #else int creat(const char*, unsigned long int); #endif char* crypt(const char*, const char*); char* ctermid(char*); char* cuserid(char*); double drand48(void); int dup(int); int dup2(int, int); int dysize(int); char* ecvt(double, int, int*, int*); char* encrypt(char*, int); double erand(short*); int execl(const char*, const char *, ...); int execle(const char*, const char *, ...); int execlp(const char*, const char*, ...); int exect(const char*, const char**, char**); int execv(const char*, const char**); int execve(const char*, const char**, char**); int execvp(const char*, const char**); void volatile exit(int); int fchmod(int, int); int fchown(int, int, int); int fcntl(int, int, ...); char* fcvt(double, int, int*, int*); int ffs(int); // on the unixpc (and other SYSVs???) flock is a data structure, not a function #if !defined(unixpc) int flock(int, int); #endif // !defined(unixpc) int fork(void); void free(void*); int fsync(int); long ftok(const char*, int); int ftruncate(int, unsigned long); char* gcvt(double, int, char*); char* getcwd(char*, int); int getdomainname(char*, int); int getdtablesize(void); int getegid(void); char* getenv(const char*); int geteuid(void); int getgid(void); int getgroups(int, int*); long gethostid(void); int gethostname(char*, int); char* getlogin(void); int getopt(int, const char**, const char*); int getpagesize(void); char* getpass(const char*); int getpgrp(...); int getpid(void); int getppid(void); int getpriority(int, int); int getpw(int, char*); unsigned getuid(void); char* getwd(char*); char* initstate(unsigned, char*, int); int ioctl(int, int, char*); int isatty(int); long jrand48(short*); int kill(int, int); int killpg(int, int); void lcong48(short*); int link(const char*, const char*); int listen(int, int); int lock(int, int, long); long lrand48(void); long lseek(int, long, int); void* malloc(unsigned); unsigned malloc_usable_size(void*); void* memalign(unsigned, unsigned); void* memccpy(void*, const void*, int, int); void* memchr(const void*, int, int); int memcmp(const void*, const void*, int); void* memcpy(void*, const void*, int); void* memset(void*, int, int); int mkdir(const char*, int); int mknod(const char*, int, int); int mkstemp(char*); char* mktemp(char*); long mrand48(void); int nice(int); long nrand48(short*); #ifdef DGUX int open(char*, int, ...); #else int open(const char*, int, ...); #endif void volatile pause(void); void perror(const char*); int pipe(int*); int profil(char*, int, int, int); int psignal(unsigned, char*); int ptrace(int, int, int, int); int putenv(const char*); int qsort(void*, int, unsigned, auto (*ptf)(void*,void*)); int rand(void); long random(void); int read(int, void*, unsigned); int readlink(const char*, char*, int); void* realloc(void*, unsigned); int rename(const char*, const char*); int rmdir(const char*); void* sbrk(int); short* seed48(short*); int send(int, char*, int, int); int setgid(int); int sethostname(char*, int); int setkey(const char*); int setpgrp(...); int setpriority(int, int, int); int setregid(int, int); int setreuid(int, int); char* setstate(char*); int setuid(int); int sigblock(int); int siginterrupt(int, int); int sigpause(int); int sigsetmask(int); unsigned sleep(unsigned); int socket(int, int, int); int srand(int); void srand48(long); void srandom(int); int stime(long*); char* strcat(char*, const char*); char* strchr(const char*, int); int strcmp(const char*, const char*); char* strcpy(char*, const char*); int strcspn(const char*, const char*); char* strdup(const char*); int strlen(const char*); char* strncat(char*, const char*, int); int strncmp(const char*, const char*, int); char* strncpy(char*, const char*, int); char* strpbrk(const char*, const char*); char* strrchr(const char*, int); int strspn(const char*, const char*); double strtod(const char*, char**); char* strtok(char*, const char*); long strtol(const char*, char**, int); void swab(void*, void*, int); int symlink(const char*, const char*); int syscall(int, ...); int system(const char*); char* tempnam(const char*, const char*); int tgetent(char*, char*); int tgetnum(char*); int tgetflag(char*); char* tgetstr(char *, char **); char* tgoto(char*, int, int); long time(long*); char* tmpnam(char*); int tputs(char *, int, auto int (*)()); int truncate(const char*, unsigned long); char* ttyname(int); int ttyslot(void); unsigned ualarm(unsigned, unsigned); long ulimit(int, long); int umask(int); int unlink(const char*); unsigned usleep(unsigned); int vadvise(int); void* valloc(unsigned); int vfork(void); int vhangup(void); int wait(int*); int write(int, const void*, unsigned); } #ifdef USG inline void bzero(void* s, int l) { memset(s, 0, l); } inline void bcopy(const void* s, void* d, int l) { memcpy(d, s, l); } inline int bcmp(const void* s, const void* t, int l) {return memcmp(s,t,l);} inline char* index(const char* s, int c) { return strchr(s, c); } inline char* rindex(const char* s, int c) { return strrchr(s, c); } #else extern "C" { int bcmp(const void*, const void*, int); void bcopy(const void*, void*, int); void bzero(void*, int); char* index(const char*, int); char* rindex(const char*, int); } #endif extern char** environ; extern volatile int errno; extern char* sys_errlist[]; extern int sys_nerr; extern char* optarg; extern int opterr; extern int optind; extern "C" void* alloca(unsigned long); #ifndef alloca #define alloca(x) __builtin_alloca(x) #endif #ifndef __GNUG__ extern "C" void *__builtin_alloca (int); #endif #endif 0707070000020176601004440000020000020000011426330460564772400002500000003627g++-include/stdarg.h// This may look like C code, but it is really -*- C++ -*- /* Copyright (C) 1988 Free Software Foundation 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 _stdarg_h #pragma once #define _stdarg_h 1 #ifndef __GNUG__ extern "C" __builtin_saveregs (); #endif typedef char *va_list; /* Amount of space required in an argument list for an arg of type TYPE. TYPE may alternatively be an expression whose type is used. */ #define __va_rounded_size(TYPE) \ (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) #if defined(sparc) # define va_start(AP, LASTARG) \ (__builtin_saveregs (), AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG))) #elif defined(mips) # define va_start(AP,LASTARG) {\ static char __vd_alist[16] = "__%%VARARGS"; /* Identify to codegen */\ __builtin_saveregs();\ (AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG)));} #else # define va_start(AP, LASTARG) \ (AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG))) #endif void va_end (va_list); /* Defined in gnulib */ #define va_end(AP) #define va_arg(AP, TYPE) \ (AP += __va_rounded_size (TYPE), \ *((TYPE *) (AP - __va_rounded_size (TYPE)))) #endif 0707070000020176611004440000020000020000010371150460564772600002500000002332g++-include/stddef.h// 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 _stddef_h #pragma once #define _stddef_h // TRUE, FALSE, bool, are now in , for ANSI compatibility typedef unsigned long size_t; typedef long int ptrdiff_t; #ifdef DGUX typedef int wchar_t; #else typedef unsigned short wchar_t; #endif #ifndef NULL #define NULL 0 #endif #endif 0707070000020176621004440000020000020000010356070460564773000002400000016763g++-include/stdio.h// 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. */ /* * Please check the following before installing this file: * * Make sure USG is #defined if you are on a USG system! * * Check the value of _NFILE against the one in your /usr/include/stdio.h. * (USG only) * * Check whether your libc.a sprintf function returns * an int (as do most) versus a char* (BSD), and (un)comment * the corresponding SPRINTF_RETURNS_INT line. * * Check the value of BUFSIZ against the one in your /usr/include/stdio.h. * * Carefully check the fields and order of _iobuf declaration against * the one in your /usr/include/stdio.h. Xenix-based systems * may need some re-ordering of _iobuf. fields. * * Note that some _IOXXX #defines may not be present in your * /usr/include/stdio.h. This is ok, so long as the ones that * are present in both are set to the same values. * * Some of the prototypes refer to functions that may not be * present in your libc.a. This is ok so long as you do not * actually call such functions. * */ #ifndef FILE #pragma once /* HAVE_VPRINTF should be set if vprintf is in libc.a HAVE_SETVBUF should be set if setvbuf is in libc.a HAVE_SETLINEBUF should be set if setlinebuf in libc.a The following are probably correct for the listed systems */ #ifdef SYSTEM_FIVE #define USG #endif #if defined(unixpc) && !defined(USG) # define USG #endif #if defined(USG) #define HAVE_VPRINTF #define HAVE_SETVBUF //#define HAVE_SETLINEBUF #elif defined(vax) || defined(sony) //#define HAVE_VPRINTF //#define HAVE_SETVBUF #define HAVE_SETLINEBUF #elif defined(sun) #define HAVE_VPRINTF #define HAVE_SETVBUF #define HAVE_SETLINEBUF #elif defined(sequent) //#define HAVE_VPRINTF //#define HAVE_SETVBUF #define HAVE_SETLINEBUF #elif defined(DGUX) #define HAVE_VPRINTF #define HAVE_SETVBUF #define HAVE_SETLINEBUF #define IOBUF_FLAG_TYPE int #define IOBUF_FILE_TYPE int #define _NFILE 64 #define IOBUF_EXTRA_FIELDS int _reserve[27]; #define SPRINTF_RETURNS_INT #define BUFEND_ENTRY_TYPE unsigned char * #define USG #elif defined(TEKTRONIX_SYSV) || defined(hp9000s300) || defined(i386) #define HAVE_VPRINTF #define HAVE_SETVBUF //#define HAVE_SETLINEBUF #define USG #elif defined(convex) //#define HAVE_VPRINTF //#define HAVE_SETVBUF #define HAVE_SETLINEBUF #define IOBUF_FILE_TYPE unsigned char #define HAVE_VOID_DOPRNT #endif #ifdef hpux #define IOBUF_FLAG_TYPE char #endif #if defined(unixpc) # define IOBUF_FLAG_TYPE char # define IOBUF_FILE_TYPE char # if !defined(_NFILE) # define _NFILE 80 # endif #endif #ifdef USG #define IOBUF_BUFSIZ_FIELD /* System V ain't got one */ #endif /* Some default definitions for things not defined machine-specifically above. */ #ifndef IOBUF_BUFSIZ_FIELD #define IOBUF_BUFSIZ_FIELD int _bufsiz; #endif #ifndef IOBUF_FLAG_TYPE #define IOBUF_FLAG_TYPE short #endif #ifndef IOBUF_FILE_TYPE #define IOBUF_FILE_TYPE char #endif #ifndef IOBUF_EXTRA_FIELDS #define IOBUF_EXTRA_FIELDS #endif #if defined(USG) && !defined(_NFILE) #define _NFILE 20 #endif #ifdef USG #define _bufend(p) _bufendtab[(p)->_file] #define _bufsiz(p) (_bufend(p) - (p)->_base) #ifndef BUFEND_ENTRY_TYPE #define BUFEND_ENTRY_TYPE char * #endif extern "C" { BUFEND_ENTRY_TYPE _bufendtab[]; } #endif /* check this -- hardly any systems need this these days */ /* #define SPRINTF_RETURNS_INT */ /* check and possibly redefine the following */ #define BUFSIZ 1024 extern struct _iobuf { int _cnt; char* _ptr; char* _base; IOBUF_BUFSIZ_FIELD IOBUF_FLAG_TYPE _flag; IOBUF_FILE_TYPE _file; IOBUF_EXTRA_FIELDS } _iob[]; typedef struct _iobuf FILE; #if defined(unixpc) extern FILE _iob2[_NFILE - 20]; #endif #define _IOFBF 00000 #define _IOREAD 00001 #define _IOWRT 00002 #define _IONBF 00004 #define _IOMYBUF 00010 #define _IOEOF 00020 #define _IOERR 00040 #if defined(USG) && !defined(hpux) #define _IOSTRG 00000 /* faked out for USG */ #define _IOLBF 00100 #define _IORW 00200 #define _IOAPPEND 00000 /* faked out for USG */ #elif defined(hpux) #define _IOSTRG 00000 /* faked out for USG */ #define _IOLBF 00200 #define _IORW 00400 #define _IOAPPEND 00000 /* faked out for USG */ #else #define _IOSTRG 00100 #define _IOLBF 00200 #define _IORW 00400 #define _IOAPPEND 01000 #endif #ifdef DGUX #define _IOPBF 00400 /* Boolean - ungetc() not called since fill/flush */ #endif #define EOF (-1) #ifndef NULL #define NULL 0 #endif #define stdin (&_iob[0]) #define stdout (&_iob[1]) #define stderr (&_iob[2]) #define getc(p) (--(p)->_cnt>=0?(int)(*(unsigned char*)(p)->_ptr++):_filbuf(p)) #define putc(x,p) (--(p)->_cnt>=0? ((int)((unsigned char)((*(p)->_ptr++=(unsigned)(x))))):_flsbuf((unsigned)(x),p)) #define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF)) #define getchar() getc(stdin) #define putchar(x) putc(x,stdout) #define feof(p) (((p)->_flag&_IOEOF)!=0) #define ferror(p) (((p)->_flag&_IOERR)!=0) #define fileno(p) ((p)->_file) extern "C" { int _doprnt(const char*, void*, FILE*); int _doscan(FILE*, const char*, ...); int _filbuf(FILE*); int _flsbuf(unsigned, FILE*); int fclose(FILE*); FILE* fdopen(int, const char*); int fflush(FILE*); int fgetc(FILE*); char* fgets(char*, int, FILE *); FILE* fopen(const char*, const char*); int fprintf(FILE*, const char* ...); int fputc(int, FILE*); int fputs(const char*, FILE*); int fread(void*, int, int, FILE*); FILE* freopen(const char*, const char*, FILE*); int fscanf(FILE*, const char* ...); int fseek(FILE*, long, int); long ftell(FILE *); int fwrite(const void*, int, int, FILE*); char* gets(char*); int getw(FILE*); int pclose(FILE*); FILE* popen(const char*, const char*); int printf(const char* ...); int puts(const char*); int putw(int, FILE*); int rewind(FILE*); int scanf(const char* ...); int setbuf(FILE*, char*); int setbuffer(FILE*, char*, int); int setlinebuf(FILE*); int setvbuf(FILE*, char*, int, int); int sscanf(char*, const char* ...); FILE* tmpfile(); int ungetc(int, FILE*); int vfprintf(FILE*, const char*, ...); // Third arg to vprintf must be '...' for some machines, & doesn't // hurt for others. int vprintf(const char*, ... ); #ifdef SPRINTF_RETURNS_INT int sprintf(char*, const char* ...); int vsprintf(char*, const char*, ...); #else char* sprintf(char*, const char* ...); char* vsprintf(char*, const char*, ...); #endif } #ifndef L_ctermid #define L_ctermid 9 #endif #ifndef L_cuserid #define L_cuserid 9 #endif #ifndef P_tmpdir #define P_tmpdir "/tmp/" #endif #ifndef L_tmpnam #define L_tmpnam (sizeof(P_tmpdir) + 15) #endif #endif // FILE 0707070000020176631004440000020000020000010356670460564773200002400000007023g++-include/AVec.hP// 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 _AVec_h #pragma once #define _AVec_h 1 #include ".Vec.h" class AVec : public Vec { protected: void check_len(int l); * vec(); AVec(int l, * d); public: AVec (); AVec (int l); AVec (int l, fill_value); AVec (AVec&); ~AVec (); AVec& operator = (AVec& a); AVec& operator = ( fill_value); // vector by scalar -> vector operations friend AVec operator + (AVec& a, b); friend AVec operator - (AVec& a, b); friend AVec operator * (AVec& a, b); friend AVec operator / (AVec& a, b); AVec& operator += ( b); AVec& operator -= ( b); AVec& operator *= ( b); AVec& operator /= ( b); // vector by vector -> vector operations friend AVec operator + (AVec& a, AVec& b); friend AVec operator - (AVec& a, AVec& b); AVec& operator += (AVec& b); AVec& operator -= (AVec& b); AVec operator - (); friend AVec product(AVec& a, AVec& b); AVec& product(AVec& b); friend AVec quotient(AVec& a, AVec& b); AVec& quotient(AVec& b); // vector -> scalar operations friend operator * (AVec& a, AVec& b); sum(); min(); max(); sumsq(); // indexing int min_index(); int max_index(); // redundant but necesssary friend AVec concat(AVec& a, AVec& b); friend AVec map(Mapper f, AVec& a); friend AVec merge(AVec& a, AVec& b, Comparator f); friend AVec combine(Combiner f, AVec& a, AVec& b); friend AVec reverse(AVec& a); AVec at(int from = 0, int n = -1); }; inline AVec::AVec() {} inline AVec::AVec(int l) :(l) {} inline AVec::AVec(int l, fill_value) : (l, fill_value) {} inline AVec::AVec(AVec& v) :(v) {} inline AVec::~AVec() {} inline * AVec::vec() { return s; } inline AVec::AVec(int l, * d) { len = l; s = d; } inline void AVec::check_len(int l) { if (l != len) error("nonconformant vectors."); } #endif 0707070000020176641004440000020000020000011606670460564773400002500000000237g++-include/stream.h/* ostream.h and istream.h now separately includable */ #ifndef _stream_h #pragma once #define _stream_h 1 #include #include #endif 0707070000020176651004440000020000020000011433100460564773700002500000000021g++-include/string.h#include 0707070000020176661004440000020000020000010667440460564774200002500000015621g++-include/curses.h// This may look like C code, but it is really -*- C++ -*- /* Copyright (C) 1989 Free Software Foundation written by Eric Newton (newton@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. */ /* * Edited for compatablity with C++, 2/28/89 * This file has all the /usr/include/curses.h info (with proper prototypes) * used for the CursesWindow classes. You may need to change this to be * compatable with your curses implementation. * */ #ifndef _curses_h #pragma once #define _curses_h # include # include # include extern "C" { # include // protection against possibility that these are macros: #ifndef stty extern int stty(int, struct sgttyb*); #endif #ifndef gtty extern int gtty(int, struct sgttyb*); #endif } typedef char cbool; // curses explicitly declares bools as chars #if defined(hpux) enum CursesStatus { ERR = -1, OK = 0 }; // curses lib uses define's #else enum CursesStatus { ERR = 0, OK = 1 }; // curses lib uses define's #endif /* * BSD'ish. Warning!! * */ # define _ENDLINE 001 # define _FULLWIN 002 # define _SCROLLWIN 004 # define _FLUSH 010 # define _FULLLINE 020 # define _IDLINE 040 # define _STANDOUT 0200 # define _NOCHANGE -1 # define _puts(s) tputs(s, 0, _putchar) /* * Capabilities from termcap */ extern cbool AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL, XB, XN, XT, XS, XX; extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL, *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6, *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL, *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF, *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS, *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM, *RIGHT_PARM; extern char PC; extern cbool GT, NONL, UPPERCASE, normtty, _pfast; struct _win_st { short _cury, _curx; short _maxy, _maxx; short _begy, _begx; short _flags; short _ch_off; cbool _clear; cbool _leave; cbool _scroll; char **_y; short *_firstch; short *_lastch; struct _win_st *_nextp, *_orig; }; #define WINDOW struct _win_st extern cbool My_term; extern cbool _echoit; extern cbool _rawmode; extern cbool _endwin; extern char *Def_term; extern char ttytype[]; extern int LINES; extern int COLS; extern int _tty_ch; extern int _res_flg; typedef struct sgttyb SGTTY; extern SGTTY _tty; /* * standard curses functions. * */ extern "C" { WINDOW * stdscr; WINDOW * curscr; WINDOW * newwin(int lines, int cols, int sy, int sx); WINDOW * subwin(WINDOW *w, int lines, int cols, int sy, int sx); WINDOW * initscr(); int box (WINDOW*, char, char); int delwin(WINDOW*); int mvcur(int, int, int, int); int overlay(WINDOW*, WINDOW*); int overwrite(WINDOW*, WINDOW*); int scroll(WINDOW*); int touchline(WINDOW*, int, int, int); #ifndef DGUX int touchoverlap(WINDOW*, WINDOW*); #endif int touchwin(WINDOW*); int waddch(WINDOW*, char); int waddstr(WINDOW*, const char*); int wclear(WINDOW*); int wclrtobot(WINDOW*); int wclrtoeol(WINDOW*); int wdelch(WINDOW*); int wdeleteln(WINDOW*); int werase(WINDOW*); int wgetch(WINDOW*); int wgetstr(WINDOW*, char*); int winch(WINDOW*); int winsch(WINDOW*, char); int winsertln(WINDOW*); int wmove(WINDOW*, int, int); int wrefresh(WINDOW*); int wstandend(WINDOW*); int wstandout(WINDOW*); int wprintw(WINDOW*, const char * fmt, ...); int mvwprintw(WINDOW*, int y, int x, const char * fmt, ...); int wscanw(WINDOW*, const char *, ...); int mvwscanw(int, int, WINDOW*, const char*, ...); int endwin(); } /* Pseudo functions */ /* * these are inlines rather than defines here so as to allow overloaded * versions in the CursesWindow class */ inline int clearok(WINDOW* win, cbool bf) { return(win->_clear = bf); } inline int leaveok(WINDOW* win, cbool bf) { return(win->_leave = bf); } inline int scrollok(WINDOW* win, cbool bf) { return(win->_scroll = bf); } inline int flushok(WINDOW* win, cbool bf) { return(bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH)); } inline void getyx(WINDOW* win, int& y, int& x) { y = win->_cury; x = win->_curx; } inline int winch(WINDOW* win) {return win->_y[win->_cury][win->_curx] & 0177; } #ifdef USG extern "C" { int raw(); int noraw(); int cbreak(); int nocbreak(); } #else inline int raw() { return _tty.sg_flags|=RAW, _pfast=_rawmode=1, stty(_tty_ch,&_tty); } inline int noraw() { return _tty.sg_flags&=~RAW,_rawmode=0,_pfast=!(_tty.sg_flags&CRMOD),stty(_tty_ch,&_tty); } inline int cbreak() { return _tty.sg_flags |= CBREAK, _rawmode = 1, stty(_tty_ch,&_tty); } inline int nocbreak() { return _tty.sg_flags &= ~CBREAK,_rawmode=0,stty(_tty_ch,&_tty); } #endif inline int crmode() { return cbreak(); } inline int nocrmode() { return nocbreak(); } #ifdef USG extern "C" { int _setecho(int); int _setnonl(int); } inline int echo() { return _setecho(1); } inline int noecho() { return _setecho(0); } inline int nl() { return _setnonl(0); } inline int nonl() { return _setnonl(1); } extern "C" { int savetty(); int resetty(); int erasechar(); int killchar(); int baudrate(); } #else inline int echo() { return _tty.sg_flags |= ECHO, _echoit = 1, stty(_tty_ch, &_tty); } inline int noecho() { return _tty.sg_flags &= ~ECHO, _echoit = 0, stty(_tty_ch, &_tty); } inline int nl() { return _tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty); } inline int nonl() { return _tty.sg_flags &= ~CRMOD, _pfast = 1, stty(_tty_ch, &_tty); } inline int savetty() { return (void) gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags; } inline int resetty() { return _tty.sg_flags = _res_flg, stty(_tty_ch, &_tty); } inline int erasechar() { return _tty.sg_erase; } inline int killchar() { return _tty.sg_kill; } inline int baudrate() { return _tty.sg_ospeed; } #endif extern "C" { char *longname(char *, char *); char *getcap(char *); extern char *_unctrl[]; } inline char * unctrl(int c) { return _unctrl[(c) & 0177]; } #endif 0707070000020176671004440000020000020000011276250460564774400002600000006402g++-include/AVLMap.hP// 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 _AVLMap_h #pragma once #define _AVLMap_h 1 #include "..Map.h" struct AVLNode { AVLNode* lt; AVLNode* rt; item; cont; char stat; AVLNode( h, c, AVLNode* l=0, AVLNode* r=0); ~AVLNode(); }; inline AVLNode::AVLNode( h, c, AVLNode* l=0, AVLNode* r=0) :item(h), cont(c), lt(l), rt(r) { stat = 0; } inline AVLNode::~AVLNode() {} typedef AVLNode* AVLNodePtr; class AVLMap : public Map { protected: AVLNode* root; AVLNode* leftmost(); AVLNode* rightmost(); AVLNode* pred(AVLNode* t); AVLNode* succ(AVLNode* t); void _kill(AVLNode* t); void _add(AVLNode*& t); void _del(AVLNode* p, AVLNode*& t); public: AVLMap( dflt); AVLMap(AVLMap& a); ~AVLMap(); & 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(); }; inline AVLMap::~AVLMap() { _kill(root); } inline AVLMap::AVLMap( dflt) :(dflt) { root = 0; } inline Pix AVLMap::first() { return Pix(leftmost()); } inline Pix AVLMap::last() { return Pix(rightmost()); } inline void AVLMap::next(Pix& i) { if (i != 0) i = Pix(succ((AVLNode*)i)); } inline void AVLMap::prev(Pix& i) { if (i != 0) i = Pix(pred((AVLNode*)i)); } inline & AVLMap::key(Pix i) { if (i == 0) error("null Pix"); return ((AVLNode*)i)->item; } inline & AVLMap::contents(Pix i) { if (i == 0) error("null Pix"); return ((AVLNode*)i)->cont; } inline void AVLMap::clear() { _kill(root); count = 0; root = 0; } inline int AVLMap::contains( key) { return seek(key) != 0; } #endif 0707070000020176701004440000020000020000010325250460564774600002700000031173g++-include/AVLMap.ccP// 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. */ #include #include #include "..AVLMap.h" /* constants & inlines for maintaining balance & thread status in tree nodes */ #define AVLBALANCEMASK 3 #define AVLBALANCED 0 #define AVLLEFTHEAVY 1 #define AVLRIGHTHEAVY 2 #define LTHREADBIT 4 #define RTHREADBIT 8 static inline int bf(AVLNode* t) { return t->stat & AVLBALANCEMASK; } static inline void set_bf(AVLNode* t, int b) { t->stat = (t->stat & ~AVLBALANCEMASK) | (b & AVLBALANCEMASK); } static inline int rthread(AVLNode* t) { return t->stat & RTHREADBIT; } static inline void set_rthread(AVLNode* t, int b) { if (b) t->stat |= RTHREADBIT; else t->stat &= ~RTHREADBIT; } static inline int lthread(AVLNode* t) { return t->stat & LTHREADBIT; } static inline void set_lthread(AVLNode* t, int b) { if (b) t->stat |= LTHREADBIT; else t->stat &= ~LTHREADBIT; } /* traversal primitives */ AVLNode* AVLMap::leftmost() { AVLNode* t = root; if (t != 0) while (t->lt != 0) t = t->lt; return t; } AVLNode* AVLMap::rightmost() { AVLNode* t = root; if (t != 0) while (t->rt != 0) t = t->rt; return t; } AVLNode* AVLMap::succ(AVLNode* t) { AVLNode* r = t->rt; if (!rthread(t)) while (!lthread(r)) r = r->lt; return r; } AVLNode* AVLMap::pred(AVLNode* t) { AVLNode* l = t->lt; if (!lthread(t)) while (!rthread(l)) l = l->rt; return l; } Pix AVLMap::seek( key) { AVLNode* t = root; if (t == 0) return 0; for (;;) { int cmp = CMP(key, t->item); if (cmp == 0) return Pix(t); else if (cmp < 0) { if (lthread(t)) return 0; else t = t->lt; } else if (rthread(t)) return 0; else t = t->rt; } } /* The combination of threads and AVL bits make adding & deleting interesting, but very awkward. We use the following statics to avoid passing them around recursively */ static int _need_rebalancing; // to send back balance info from rec. calls static * _target_item; // add/del_item target static AVLNode* _found_node; // returned added/deleted node static int _already_found; // for deletion subcases void AVLMap:: _add(AVLNode*& t) { int cmp = CMP(*_target_item, t->item); if (cmp == 0) { _found_node = t; return; } else if (cmp < 0) { if (lthread(t)) { ++count; _found_node = new AVLNode(*_target_item, def); set_lthread(_found_node, 1); set_rthread(_found_node, 1); _found_node->lt = t->lt; _found_node->rt = t; t->lt = _found_node; set_lthread(t, 0); _need_rebalancing = 1; } else _add(t->lt); if (_need_rebalancing) { switch(bf(t)) { case AVLRIGHTHEAVY: set_bf(t, AVLBALANCED); _need_rebalancing = 0; return; case AVLBALANCED: set_bf(t, AVLLEFTHEAVY); return; case AVLLEFTHEAVY: AVLNode* l = t->lt; if (bf(l) == AVLLEFTHEAVY) { if (rthread(l)) t->lt = l; else t->lt = l->rt; set_lthread(t, rthread(l)); l->rt = t; set_rthread(l, 0); set_bf(t, AVLBALANCED); set_bf(l, AVLBALANCED); t = l; _need_rebalancing = 0; } else { AVLNode* r = l->rt; set_rthread(l, lthread(r)); if (lthread(r)) l->rt = r; else l->rt = r->lt; r->lt = l; set_lthread(r, 0); set_lthread(t, rthread(r)); if (rthread(r)) t->lt = r; else t->lt = r->rt; r->rt = t; set_rthread(r, 0); if (bf(r) == AVLLEFTHEAVY) set_bf(t, AVLRIGHTHEAVY); else set_bf(t, AVLBALANCED); if (bf(r) == AVLRIGHTHEAVY) set_bf(l, AVLLEFTHEAVY); else set_bf(l, AVLBALANCED); set_bf(r, AVLBALANCED); t = r; _need_rebalancing = 0; return; } } } } else { if (rthread(t)) { ++count; _found_node = new AVLNode(*_target_item, def); set_rthread(t, 0); set_lthread(_found_node, 1); set_rthread(_found_node, 1); _found_node->lt = t; _found_node->rt = t->rt; t->rt = _found_node; _need_rebalancing = 1; } else _add(t->rt); if (_need_rebalancing) { switch(bf(t)) { case AVLLEFTHEAVY: set_bf(t, AVLBALANCED); _need_rebalancing = 0; return; case AVLBALANCED: set_bf(t, AVLRIGHTHEAVY); return; case AVLRIGHTHEAVY: AVLNode* r = t->rt; if (bf(r) == AVLRIGHTHEAVY) { if (lthread(r)) t->rt = r; else t->rt = r->lt; set_rthread(t, lthread(r)); r->lt = t; set_lthread(r, 0); set_bf(t, AVLBALANCED); set_bf(r, AVLBALANCED); t = r; _need_rebalancing = 0; } else { AVLNode* l = r->lt; set_lthread(r, rthread(l)); if (rthread(l)) r->lt = l; else r->lt = l->rt; l->rt = r; set_rthread(l, 0); set_rthread(t, lthread(l)); if (lthread(l)) t->rt = l; else t->rt = l->lt; l->lt = t; set_lthread(l, 0); if (bf(l) == AVLRIGHTHEAVY) set_bf(t, AVLLEFTHEAVY); else set_bf(t, AVLBALANCED); if (bf(l) == AVLLEFTHEAVY) set_bf(r, AVLRIGHTHEAVY); else set_bf(r, AVLBALANCED); set_bf(l, AVLBALANCED); t = l; _need_rebalancing = 0; return; } } } } } & AVLMap::operator [] ( item) { if (root == 0) { ++count; root = new AVLNode(item, def); set_rthread(root, 1); set_lthread(root, 1); return root->cont; } else { _target_item = &item; _need_rebalancing = 0; _add(root); return _found_node->cont; } } void AVLMap::_del(AVLNode* par, AVLNode*& t) { int comp; if (_already_found) { if (rthread(t)) comp = 0; else comp = 1; } else comp = CMP(*_target_item, t->item); if (comp == 0) { if (lthread(t) && rthread(t)) { _found_node = t; if (t == par->lt) { set_lthread(par, 1); par->lt = t->lt; } else { set_rthread(par, 1); par->rt = t->rt; } _need_rebalancing = 1; return; } else if (lthread(t)) { _found_node = t; AVLNode* s = succ(t); if (s != 0 && lthread(s)) s->lt = t->lt; t = t->rt; _need_rebalancing = 1; return; } else if (rthread(t)) { _found_node = t; AVLNode* p = pred(t); if (p != 0 && rthread(p)) p->rt = t->rt; t = t->lt; _need_rebalancing = 1; return; } else // replace item & find someone deletable { AVLNode* p = pred(t); t->item = p->item; t->cont = p->cont; _already_found = 1; comp = -1; // fall through below to left } } if (comp < 0) { if (lthread(t)) return; _del(t, t->lt); if (!_need_rebalancing) return; switch (bf(t)) { case AVLLEFTHEAVY: set_bf(t, AVLBALANCED); return; case AVLBALANCED: set_bf(t, AVLRIGHTHEAVY); _need_rebalancing = 0; return; case AVLRIGHTHEAVY: AVLNode* r = t->rt; switch (bf(r)) { case AVLBALANCED: if (lthread(r)) t->rt = r; else t->rt = r->lt; set_rthread(t, lthread(r)); r->lt = t; set_lthread(r, 0); set_bf(t, AVLRIGHTHEAVY); set_bf(r, AVLLEFTHEAVY); _need_rebalancing = 0; t = r; return; case AVLRIGHTHEAVY: if (lthread(r)) t->rt = r; else t->rt = r->lt; set_rthread(t, lthread(r)); r->lt = t; set_lthread(r, 0); set_bf(t, AVLBALANCED); set_bf(r, AVLBALANCED); t = r; return; case AVLLEFTHEAVY: AVLNode* l = r->lt; set_lthread(r, rthread(l)); if (rthread(l)) r->lt = l; else r->lt = l->rt; l->rt = r; set_rthread(l, 0); set_rthread(t, lthread(l)); if (lthread(l)) t->rt = l; else t->rt = l->lt; l->lt = t; set_lthread(l, 0); if (bf(l) == AVLRIGHTHEAVY) set_bf(t, AVLLEFTHEAVY); else set_bf(t, AVLBALANCED); if (bf(l) == AVLLEFTHEAVY) set_bf(r, AVLRIGHTHEAVY); else set_bf(r, AVLBALANCED); set_bf(l, AVLBALANCED); t = l; return; } } } else { if (rthread(t)) return; _del(t, t->rt); if (!_need_rebalancing) return; switch (bf(t)) { case AVLRIGHTHEAVY: set_bf(t, AVLBALANCED); return; case AVLBALANCED: set_bf(t, AVLLEFTHEAVY); _need_rebalancing = 0; return; case AVLLEFTHEAVY: AVLNode* l = t->lt; switch (bf(l)) { case AVLBALANCED: if (rthread(l)) t->lt = l; else t->lt = l->rt; set_lthread(t, rthread(l)); l->rt = t; set_rthread(l, 0); set_bf(t, AVLLEFTHEAVY); set_bf(l, AVLRIGHTHEAVY); _need_rebalancing = 0; t = l; return; case AVLLEFTHEAVY: if (rthread(l)) t->lt = l; else t->lt = l->rt; set_lthread(t, rthread(l)); l->rt = t; set_rthread(l, 0); set_bf(t, AVLBALANCED); set_bf(l, AVLBALANCED); t = l; return; case AVLRIGHTHEAVY: AVLNode* r = l->rt; set_rthread(l, lthread(r)); if (lthread(r)) l->rt = r; else l->rt = r->lt; r->lt = l; set_lthread(r, 0); set_lthread(t, rthread(r)); if (rthread(r)) t->lt = r; else t->lt = r->rt; r->rt = t; set_rthread(r, 0); if (bf(r) == AVLLEFTHEAVY) set_bf(t, AVLRIGHTHEAVY); else set_bf(t, AVLBALANCED); if (bf(r) == AVLRIGHTHEAVY) set_bf(l, AVLLEFTHEAVY); else set_bf(l, AVLBALANCED); set_bf(r, AVLBALANCED); t = r; return; } } } } void AVLMap::del( item) { if (root == 0) return; _need_rebalancing = 0; _already_found = 0; _found_node = 0; _target_item = &item; _del(root, root); if (_found_node) { delete(_found_node); if (--count == 0) root = 0; } } void AVLMap::_kill(AVLNode* t) { if (t != 0) { if (!lthread(t)) _kill(t->lt); if (!rthread(t)) _kill(t->rt); delete t; } } AVLMap::AVLMap(AVLMap& b) :(b.def) { root = 0; count = 0; for (Pix i = b.first(); i != 0; b.next(i)) (*this)[b.key(i)] = b.contents(i); } int AVLMap::OK() { int v = 1; if (root == 0) v = count == 0; else { int n = 1; AVLNode* trail = leftmost(); AVLNode* t = succ(trail); while (t != 0) { ++n; v &= CMP(trail->item, t->item) < 0; trail = t; t = succ(t); } v &= n == count; } if (!v) error("invariant failure"); return v; } 0707070000020176711004440000020000020000011117660460564775100002700000042033g++-include/AVLSet.ccP// 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. */ #include #include #include ".AVLSet.h" /* constants & inlines for maintaining balance & thread status in tree nodes */ #define AVLBALANCEMASK 3 #define AVLBALANCED 0 #define AVLLEFTHEAVY 1 #define AVLRIGHTHEAVY 2 #define LTHREADBIT 4 #define RTHREADBIT 8 static inline int bf(AVLNode* t) { return t->stat & AVLBALANCEMASK; } static inline void set_bf(AVLNode* t, int b) { t->stat = (t->stat & ~AVLBALANCEMASK) | (b & AVLBALANCEMASK); } static inline int rthread(AVLNode* t) { return t->stat & RTHREADBIT; } static inline void set_rthread(AVLNode* t, int b) { if (b) t->stat |= RTHREADBIT; else t->stat &= ~RTHREADBIT; } static inline int lthread(AVLNode* t) { return t->stat & LTHREADBIT; } static inline void set_lthread(AVLNode* t, int b) { if (b) t->stat |= LTHREADBIT; else t->stat &= ~LTHREADBIT; } /* traversal primitives */ AVLNode* AVLSet::leftmost() { AVLNode* t = root; if (t != 0) while (t->lt != 0) t = t->lt; return t; } AVLNode* AVLSet::rightmost() { AVLNode* t = root; if (t != 0) while (t->rt != 0) t = t->rt; return t; } AVLNode* AVLSet::succ(AVLNode* t) { AVLNode* r = t->rt; if (!rthread(t)) while (!lthread(r)) r = r->lt; return r; } AVLNode* AVLSet::pred(AVLNode* t) { AVLNode* l = t->lt; if (!lthread(t)) while (!rthread(l)) l = l->rt; return l; } Pix AVLSet::seek( key) { AVLNode* t = root; if (t == 0) return 0; for (;;) { int cmp = CMP(key, t->item); if (cmp == 0) return Pix(t); else if (cmp < 0) { if (lthread(t)) return 0; else t = t->lt; } else if (rthread(t)) return 0; else t = t->rt; } } /* The combination of threads and AVL bits make adding & deleting interesting, but very awkward. We use the following statics to avoid passing them around recursively */ static int _need_rebalancing; // to send back balance info from rec. calls static * _target_item; // add/del_item target static AVLNode* _found_node; // returned added/deleted node static int _already_found; // for deletion subcases static AVLNode** _hold_nodes; // used for rebuilding trees static int _max_hold_index; // # elements-1 in _hold_nodes void AVLSet:: _add(AVLNode*& t) { int cmp = CMP(*_target_item, t->item); if (cmp == 0) { _found_node = t; return; } else if (cmp < 0) { if (lthread(t)) { ++count; _found_node = new AVLNode(*_target_item); set_lthread(_found_node, 1); set_rthread(_found_node, 1); _found_node->lt = t->lt; _found_node->rt = t; t->lt = _found_node; set_lthread(t, 0); _need_rebalancing = 1; } else _add(t->lt); if (_need_rebalancing) { switch(bf(t)) { case AVLRIGHTHEAVY: set_bf(t, AVLBALANCED); _need_rebalancing = 0; return; case AVLBALANCED: set_bf(t, AVLLEFTHEAVY); return; case AVLLEFTHEAVY: AVLNode* l = t->lt; if (bf(l) == AVLLEFTHEAVY) { if (rthread(l)) t->lt = l; else t->lt = l->rt; set_lthread(t, rthread(l)); l->rt = t; set_rthread(l, 0); set_bf(t, AVLBALANCED); set_bf(l, AVLBALANCED); t = l; _need_rebalancing = 0; } else { AVLNode* r = l->rt; set_rthread(l, lthread(r)); if (lthread(r)) l->rt = r; else l->rt = r->lt; r->lt = l; set_lthread(r, 0); set_lthread(t, rthread(r)); if (rthread(r)) t->lt = r; else t->lt = r->rt; r->rt = t; set_rthread(r, 0); if (bf(r) == AVLLEFTHEAVY) set_bf(t, AVLRIGHTHEAVY); else set_bf(t, AVLBALANCED); if (bf(r) == AVLRIGHTHEAVY) set_bf(l, AVLLEFTHEAVY); else set_bf(l, AVLBALANCED); set_bf(r, AVLBALANCED); t = r; _need_rebalancing = 0; return; } } } } else { if (rthread(t)) { ++count; _found_node = new AVLNode(*_target_item); set_rthread(t, 0); set_lthread(_found_node, 1); set_rthread(_found_node, 1); _found_node->lt = t; _found_node->rt = t->rt; t->rt = _found_node; _need_rebalancing = 1; } else _add(t->rt); if (_need_rebalancing) { switch(bf(t)) { case AVLLEFTHEAVY: set_bf(t, AVLBALANCED); _need_rebalancing = 0; return; case AVLBALANCED: set_bf(t, AVLRIGHTHEAVY); return; case AVLRIGHTHEAVY: AVLNode* r = t->rt; if (bf(r) == AVLRIGHTHEAVY) { if (lthread(r)) t->rt = r; else t->rt = r->lt; set_rthread(t, lthread(r)); r->lt = t; set_lthread(r, 0); set_bf(t, AVLBALANCED); set_bf(r, AVLBALANCED); t = r; _need_rebalancing = 0; } else { AVLNode* l = r->lt; set_lthread(r, rthread(l)); if (rthread(l)) r->lt = l; else r->lt = l->rt; l->rt = r; set_rthread(l, 0); set_rthread(t, lthread(l)); if (lthread(l)) t->rt = l; else t->rt = l->lt; l->lt = t; set_lthread(l, 0); if (bf(l) == AVLRIGHTHEAVY) set_bf(t, AVLLEFTHEAVY); else set_bf(t, AVLBALANCED); if (bf(l) == AVLLEFTHEAVY) set_bf(r, AVLRIGHTHEAVY); else set_bf(r, AVLBALANCED); set_bf(l, AVLBALANCED); t = l; _need_rebalancing = 0; return; } } } } } Pix AVLSet::add( item) { if (root == 0) { ++count; root = new AVLNode(item); set_rthread(root, 1); set_lthread(root, 1); return Pix(root); } else { _target_item = &item; _need_rebalancing = 0; _add(root); return Pix(_found_node); } } void AVLSet::_del(AVLNode* par, AVLNode*& t) { int comp; if (_already_found) { if (rthread(t)) comp = 0; else comp = 1; } else comp = CMP(*_target_item, t->item); if (comp == 0) { if (lthread(t) && rthread(t)) { _found_node = t; if (t == par->lt) { set_lthread(par, 1); par->lt = t->lt; } else { set_rthread(par, 1); par->rt = t->rt; } _need_rebalancing = 1; return; } else if (lthread(t)) { _found_node = t; AVLNode* s = succ(t); if (s != 0 && lthread(s)) s->lt = t->lt; t = t->rt; _need_rebalancing = 1; return; } else if (rthread(t)) { _found_node = t; AVLNode* p = pred(t); if (p != 0 && rthread(p)) p->rt = t->rt; t = t->lt; _need_rebalancing = 1; return; } else // replace item & find someone deletable { AVLNode* p = pred(t); t->item = p->item; _already_found = 1; comp = -1; // fall through below to left } } if (comp < 0) { if (lthread(t)) return; _del(t, t->lt); if (!_need_rebalancing) return; switch (bf(t)) { case AVLLEFTHEAVY: set_bf(t, AVLBALANCED); return; case AVLBALANCED: set_bf(t, AVLRIGHTHEAVY); _need_rebalancing = 0; return; case AVLRIGHTHEAVY: AVLNode* r = t->rt; switch (bf(r)) { case AVLBALANCED: if (lthread(r)) t->rt = r; else t->rt = r->lt; set_rthread(t, lthread(r)); r->lt = t; set_lthread(r, 0); set_bf(t, AVLRIGHTHEAVY); set_bf(r, AVLLEFTHEAVY); _need_rebalancing = 0; t = r; return; case AVLRIGHTHEAVY: if (lthread(r)) t->rt = r; else t->rt = r->lt; set_rthread(t, lthread(r)); r->lt = t; set_lthread(r, 0); set_bf(t, AVLBALANCED); set_bf(r, AVLBALANCED); t = r; return; case AVLLEFTHEAVY: AVLNode* l = r->lt; set_lthread(r, rthread(l)); if (rthread(l)) r->lt = l; else r->lt = l->rt; l->rt = r; set_rthread(l, 0); set_rthread(t, lthread(l)); if (lthread(l)) t->rt = l; else t->rt = l->lt; l->lt = t; set_lthread(l, 0); if (bf(l) == AVLRIGHTHEAVY) set_bf(t, AVLLEFTHEAVY); else set_bf(t, AVLBALANCED); if (bf(l) == AVLLEFTHEAVY) set_bf(r, AVLRIGHTHEAVY); else set_bf(r, AVLBALANCED); set_bf(l, AVLBALANCED); t = l; return; } } } else { if (rthread(t)) return; _del(t, t->rt); if (!_need_rebalancing) return; switch (bf(t)) { case AVLRIGHTHEAVY: set_bf(t, AVLBALANCED); return; case AVLBALANCED: set_bf(t, AVLLEFTHEAVY); _need_rebalancing = 0; return; case AVLLEFTHEAVY: AVLNode* l = t->lt; switch (bf(l)) { case AVLBALANCED: if (rthread(l)) t->lt = l; else t->lt = l->rt; set_lthread(t, rthread(l)); l->rt = t; set_rthread(l, 0); set_bf(t, AVLLEFTHEAVY); set_bf(l, AVLRIGHTHEAVY); _need_rebalancing = 0; t = l; return; case AVLLEFTHEAVY: if (rthread(l)) t->lt = l; else t->lt = l->rt; set_lthread(t, rthread(l)); l->rt = t; set_rthread(l, 0); set_bf(t, AVLBALANCED); set_bf(l, AVLBALANCED); t = l; return; case AVLRIGHTHEAVY: AVLNode* r = l->rt; set_rthread(l, lthread(r)); if (lthread(r)) l->rt = r; else l->rt = r->lt; r->lt = l; set_lthread(r, 0); set_lthread(t, rthread(r)); if (rthread(r)) t->lt = r; else t->lt = r->rt; r->rt = t; set_rthread(r, 0); if (bf(r) == AVLLEFTHEAVY) set_bf(t, AVLRIGHTHEAVY); else set_bf(t, AVLBALANCED); if (bf(r) == AVLRIGHTHEAVY) set_bf(l, AVLLEFTHEAVY); else set_bf(l, AVLBALANCED); set_bf(r, AVLBALANCED); t = r; return; } } } } void AVLSet::del( item) { if (root == 0) return; _need_rebalancing = 0; _already_found = 0; _found_node = 0; _target_item = &item; _del(root, root); if (_found_node) { delete(_found_node); if (--count == 0) root = 0; } } // build an ordered array of pointers to tree nodes back into a tree // we know that at least one element exists static AVLNode* _do_treeify(int lo, int hi, int& h) { int lh, rh; int mid = (lo + hi) / 2; AVLNode* t = _hold_nodes[mid]; if (lo > mid - 1) { set_lthread(t, 1); if (mid == 0) t->lt = 0; else t->lt = _hold_nodes[mid-1]; lh = 0; } else { set_lthread(t, 0); t->lt = _do_treeify(lo, mid-1, lh); } if (hi < mid + 1) { set_rthread(t, 1); if (mid == _max_hold_index) t->rt = 0; else t->rt = _hold_nodes[mid+1]; rh = 0; } else { set_rthread(t, 0); t->rt = _do_treeify(mid+1, hi, rh); } if (lh == rh) { set_bf(t, AVLBALANCED); h = lh + 1; } else if (lh == rh - 1) { set_bf(t, AVLRIGHTHEAVY); h = rh + 1; } else if (rh == lh - 1) { set_bf(t, AVLLEFTHEAVY); h = lh + 1; } else // can't happen abort(); return t; } static AVLNode* _treeify(int n) { AVLNode* t; if (n == 0) t = 0; else { int b; _max_hold_index = n-1; t = _do_treeify(0, _max_hold_index, b); } delete _hold_nodes; return t; } void AVLSet::_kill(AVLNode* t) { if (t != 0) { if (!lthread(t)) _kill(t->lt); if (!rthread(t)) _kill(t->rt); delete t; } } AVLSet::AVLSet(AVLSet& b) { if ((count = b.count) == 0) { root = 0; } else { _hold_nodes = new AVLNodePtr [count]; AVLNode* t = b.leftmost(); int i = 0; while (t != 0) { _hold_nodes[i++] = new AVLNode(t->item); t = b.succ(t); } root = _treeify(count); } } int AVLSet::operator == (AVLSet& y) { if (count != y.count) return 0; else { AVLNode* t = leftmost(); AVLNode* u = y.leftmost(); for (;;) { if (t == 0) return 1; else if (!(EQ(t->item, u->item))) return 0; else { t = succ(t); u = y.succ(u); } } } } int AVLSet::operator <= (AVLSet& y) { if (count > y.count) return 0; else { AVLNode* t = leftmost(); AVLNode* u = y.leftmost(); for (;;) { if (t == 0) return 1; else if (u == 0) return 0; int cmp = CMP(t->item, u->item); if (cmp == 0) { t = succ(t); u = y.succ(u); } else if (cmp < 0) return 0; else u = y.succ(u); } } } void AVLSet::operator |=(AVLSet& y) { AVLNode* t = leftmost(); AVLNode* u = y.leftmost(); int rsize = count + y.count; _hold_nodes = new AVLNodePtr [rsize]; int k = 0; for (;;) { if (t == 0) { while (u != 0) { _hold_nodes[k++] = new AVLNode(u->item); u = y.succ(u); } break; } else if (u == 0) { while (t != 0) { _hold_nodes[k++] = t; t = succ(t); } break; } int cmp = CMP(t->item, u->item); if (cmp == 0) { _hold_nodes[k++] = t; t = succ(t); u = y.succ(u); } else if (cmp < 0) { _hold_nodes[k++] = t; t = succ(t); } else { _hold_nodes[k++] = new AVLNode(u->item); u = y.succ(u); } } root = _treeify(k); count = k; } void AVLSet::operator &= (AVLSet& y) { AVLNode* t = leftmost(); AVLNode* u = y.leftmost(); int rsize = count AVLNodePtr [rsize]; int k = 0; for (;;) { if (t == 0) break; if (u == 0) { while (t != 0) { AVLNode* tmp = succ(t); delete t; t = tmp; } break; } int cmp = CMP(t->item, u->item); if (cmp == 0) { _hold_nodes[k++] = t; t = succ(t); u = y.succ(u); } else if (cmp < 0) { AVLNode* tmp = succ(t); delete t; t = tmp; } else u = y.succ(u); } root = _treeify(k); count = k; } void AVLSet::operator -=(AVLSet& y) { AVLNode* t = leftmost(); AVLNode* u = y.leftmost(); int rsize = count; _hold_nodes = new AVLNodePtr [rsize]; int k = 0; for (;;) { if (t == 0) break; else if (u == 0) { while (t != 0) { _hold_nodes[k++] = t; t = succ(t); } break; } int cmp = CMP(t->item, u->item); if (cmp == 0) { AVLNode* tmp = succ(t); delete t; t = tmp; u = y.succ(u); } else if (cmp < 0) { _hold_nodes[k++] = t; t = succ(t); } else u = y.succ(u); } root = _treeify(k); count = k; } int AVLSet::owns(Pix i) { if (i == 0) return 0; for (AVLNode* t = leftmost(); t != 0; t = succ(t)) if (Pix(t) == i) return 1; return 0; } int AVLSet::OK() { int v = 1; if (root == 0) v = count == 0; else { int n = 1; AVLNode* trail = leftmost(); AVLNode* t = succ(trail); while (t != 0) { ++n; v &= CMP(trail->item, t->item) < 0; trail = t; t = succ(t); } v &= n == count; } if (!v) error("invariant failure"); return v; } 0707070000020176721004440000020000020000010615010460564775300002600000006517g++-include/AVLSet.hP// 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 _AVL_h #pragma once #define _AVL_h 1 #include ".Set.h" struct AVLNode { AVLNode* lt; AVLNode* rt; item; char stat; AVLNode( h, AVLNode* l=0, AVLNode* r=0); ~AVLNode(); }; inline AVLNode::AVLNode( h, AVLNode* l=0, AVLNode* r=0) { item = h; lt = l; rt = r; stat = 0; } inline AVLNode::~AVLNode() {} typedef AVLNode* AVLNodePtr; class AVLSet : public Set { protected: AVLNode* root; AVLSet(AVLNode* p, int l); AVLNode* leftmost(); AVLNode* rightmost(); AVLNode* pred(AVLNode* t); AVLNode* succ(AVLNode* t); void _kill(AVLNode* t); void _add(AVLNode*& t); void _del(AVLNode* p, AVLNode*& t); public: AVLSet(); AVLSet(AVLSet& a); ~AVLSet(); 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); Pix last(); void prev(Pix& i); void operator |= (AVLSet& b); void operator -= (AVLSet& b); void operator &= (AVLSet& b); int operator == (AVLSet& b); int operator != (AVLSet& b); int operator <= (AVLSet& b); int OK(); }; inline AVLSet::~AVLSet() { _kill(root); } inline AVLSet::AVLSet() { root = 0; count = 0; } inline AVLSet::AVLSet(AVLNode* p, int l) { root = p; count = l; } inline int AVLSet::operator != (AVLSet& b) { return ! ((*this) == b); } inline Pix AVLSet::first() { return Pix(leftmost()); } inline Pix AVLSet::last() { return Pix(rightmost()); } inline void AVLSet::next(Pix& i) { if (i != 0) i = Pix(succ((AVLNode*)i)); } inline void AVLSet::prev(Pix& i) { if (i != 0) i = Pix(pred((AVLNode*)i)); } inline & AVLSet::operator () (Pix i) { if (i == 0) error("null Pix"); return ((AVLNode*)i)->item; } inline void AVLSet::clear() { _kill(root); count = 0; root = 0; } inline int AVLSet::contains( key) { return seek(key) != 0; } #endif 0707070000020176731004440000020000020000010263710460564775500002500000017705g++-include/AVec.ccP// 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. */ #include #include ".AVec.h" /* The following brought to you by the department of redundancy department */ AVec& AVec::operator = (AVec& v) { if (len != 0 && len != v.capacity()) error("nonconformant vectors."); if (len == 0) s = new [len = v.capacity()]; if (s != v.vec()) { for (int i = 0; i < len; ++i) s[i] = v.vec()[i]; } return *this; } AVec& AVec::operator = ( f) { for (int i = 0; i < len; ++i) s[i] = f; return *this; } AVec concat(AVec & a, AVec & b) { int newl = a.capacity() + b.capacity(); * news = new [newl]; * p = news; * top = &(a.vec()[a.capacity()]); * t = a.vec(); while (t < top) *p++ = *t++; top = &(b.vec()[b.capacity()]); t = b.vec(); while (t < top) *p++ = *t++; return AVec(newl, news); } AVec combine(Combiner f, AVec& a, AVec& b) { int newl = a.capacity() * news = new [newl]; * p = news; * top = &(a.vec()[newl]); * t = a.vec(); * u = b.vec(); while (t < top) *p++ = (*f)(*t++, *u++); return AVec(newl, news); } AVec reverse(AVec& a) { * news = new [a.capacity()]; if (a.capacity() != 0) { * lo = news; * hi = &(news[a.capacity() - 1]); while (lo < hi) { tmp = *lo; *lo++ = *hi; *hi-- = tmp; } } return AVec(a.capacity(), news); } AVec map(Mapper f, AVec& a) { * news = new [a.capacity()]; * p = news; * top = &(a.vec()[a.capacity()]); * t = a.vec(); while(t < top) *p++ = (*f)(*t++); return AVec(a.capacity(), news); } AVec AVec::at(int from = 0, int n = -1) { int to; if (n < 0) { n = len - from; to = len - 1; } else to = from + n - 1; if ((unsigned)from > to) range_error(); * news = new [n]; * p = news; * t = &(s[from]); * top = &(s[to]); while (t <= top) *p++ = *t++; return AVec(n, news); } AVec merge(AVec & a, AVec & b, Comparator f) { int newl = a.capacity() + b.capacity(); * news = new [newl]; * p = news; * topa = &(a.vec()[a.capacity()]); * as = a.vec(); * topb = &(b.vec()[b.capacity()]); * bs = b.vec(); for (;;) { if (as >= topa) { while (bs < topb) *p++ = *bs++; break; } else if (bs >= topb) { while (as < topa) *p++ = *as++; break; } else if ((*f)(*as, *bs) <= 0) *p++ = *as++; else *p++ = *bs++; } return AVec(newl, news); } AVec operator + (AVec& a, AVec& b) { a.check_len(b.capacity()); * news = new [a.capacity()]; * p = news; * top = &(a.vec()[a.capacity()]); * t = a.vec(); * u = b.vec(); while (t < top) *p++ = *t++ + *u++; return AVec(a.capacity(), news); } AVec operator - (AVec& a, AVec& b) { a.check_len(b.capacity()); * news = new [a.capacity()]; * p = news; * top = &(a.vec()[a.capacity()]); * t = a.vec(); * u = b.vec(); while (t < top) *p++ = *t++ - *u++; return AVec(a.capacity(), news); } AVec product (AVec& a, AVec& b) { a.check_len(b.capacity()); * news = new [a.capacity()]; * p = news; * top = &(a.vec()[a.capacity()]); * t = a.vec(); * u = b.vec(); while (t < top) *p++ = *t++ * *u++; return AVec(a.capacity(), news); } AVec quotient(AVec& a, AVec& b) { a.check_len(b.capacity()); * news = new [a.capacity()]; * p = news; * top = &(a.vec()[a.capacity()]); * t = a.vec(); * u = b.vec(); while (t < top) *p++ = *t++ / *u++; return AVec(a.capacity(), news); } AVec operator + (AVec& a, b) { * news = new [a.capacity()]; * p = news; * top = &(a.vec()[a.capacity()]); * t = a.vec(); while (t < top) *p++ = *t++ + b; return AVec(a.capacity(), news); } AVec operator - (AVec& a, b) { * news = new [a.capacity()]; * p = news; * top = &(a.vec()[a.capacity()]); * t = a.vec(); while (t < top) *p++ = *t++ - b; return AVec(a.capacity(), news); } AVec operator * (AVec& a, b) { * news = new [a.capacity()]; * p = news; * top = &(a.vec()[a.capacity()]); * t = a.vec(); while (t < top) *p++ = *t++ * b; return AVec(a.capacity(), news); } AVec operator / (AVec& a, b) { * news = new [a.capacity()]; * p = news; * top = &(a.vec()[a.capacity()]); * t = a.vec(); while (t < top) *p++ = *t++ / b; return AVec(a.capacity(), news); } AVec AVec::operator - () { * news = new [len]; * p = news; * top = &(s[len]); * t = s; while (t < top) *p++ = -(*t++); return AVec(len, news); } AVec& AVec::operator += (AVec& b) { check_len(b.capacity()); * u = b.vec(); * top = &(s[len]); * t = s; while (t < top) *t++ += *u++; return *this; } AVec& AVec::operator -= (AVec& b) { check_len(b.capacity()); * u = b.vec(); * top = &(s[len]); * t = s; while (t < top) *t++ -= *u++; return *this; } AVec& AVec::product(AVec& b) { check_len(b.capacity()); * u = b.vec(); * top = &(s[len]); * t = s; while (t < top) *t++ *= *u++; return *this; } AVec& AVec::quotient(AVec& b) { check_len(b.capacity()); * u = b.vec(); * top = &(s[len]); * t = s; while (t < top) *t++ /= *u++; return *this; } AVec& AVec::operator += ( b) { * top = &(s[len]); * t = s; while (t < top) *t++ += b; return *this; } AVec& AVec::operator -= ( b) { * top = &(s[len]); * t = s; while (t < top) *t++ -= b; return *this; } AVec& AVec::operator *= ( b) { * top = &(s[len]); * t = s; while (t < top) *t++ *= b; return *this; } AVec& AVec::operator /= ( b) { * top = &(s[len]); * t = s; while (t < top) *t++ /= b; return *this; } AVec::max() { if (len == 0) return 0; * top = &(s[len]); * t = s; res = *t++; for (; t < top; ++t) if (*t > res) res = *t; return res; } int AVec::max_index() { if (len == 0) return -1; int ind = 0; for (int i = 1; i < len; ++i) if (s[i] > s[ind]) ind = i; return ind; } AVec::min() { if (len == 0) return 0; * top = &(s[len]); * t = s; res = *t++; for (; t < top; ++t) if (*t < res) res = *t; return res; } int AVec::min_index() { if (len == 0) return -1; int ind = 0; for (int i = 1; i < len; ++i) if (s[i] < s[ind]) ind = i; return ind; } AVec::sum() { res = 0; * top = &(s[len]); * t = s; while (t < top) res += *t++; return res; } AVec::sumsq() { res = 0; * top = &(s[len]); * t = s; for (; t < top; ++t) res += *t * *t; return res; } operator * (AVec& a, AVec& b) { a.check_len(b.capacity()); * top = &(a.vec()[a.capacity()]); * t = a.vec(); * u = b.vec(); res = 0; while (t < top) res += *t++ * *u++; return res; } 0707070000020176741004440000020000020000010662750460564775700002700000016142g++-include/BSTSet.ccP// 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. */ #include #include ".BSTSet.h" /* traversal primitives */ BSTNode* BSTSet::leftmost() { BSTNode* t = root; if (t != 0) while (t->lt != 0) t = t->lt; return t; } BSTNode* BSTSet::rightmost() { BSTNode* t = root; if (t != 0) while (t->rt != 0) t = t->rt; return t; } BSTNode* BSTSet::succ(BSTNode* t) { if (t == 0) return 0; if (t->rt != 0) { t = t->rt; while (t->lt != 0) t = t->lt; return t; } else { for (;;) { if (t->par == 0 || t == t->par->lt) return t->par; else t = t->par; } } } BSTNode* BSTSet::pred(BSTNode* t) { if (t == 0) return 0; else if (t->lt != 0) { t = t->lt; while (t->rt != 0) t = t->rt; return t; } else { for (;;) { if (t->par == 0 || t == t->par->rt) return t->par; else t = t->par; } } } Pix BSTSet::seek( key) { BSTNode* t = root; for (;;) { if (t == 0) return 0; int comp = CMP(key, t->item); if (comp == 0) return Pix(t); else if (comp < 0) t = t->lt; else t = t->rt; } } Pix BSTSet::add( item) { if (root == 0) { ++count; root = new BSTNode(item); return Pix(root); } BSTNode* t = root; BSTNode* p = root; int comp; for (;;) { if (t == 0) { ++count; t = new BSTNode(item); if (comp > 0) p->lt = t; else p->rt = t; t->par = p; return Pix(t); } p = t; comp = CMP(t->item, item); if (comp == 0) return Pix(t); else if (comp > 0) t = t->lt; else t = t->rt; } } void BSTSet::del( key) { BSTNode* t = root; BSTNode* p = root; int comp; for (;;) { if (t == 0) return; comp = CMP(key, t->item); if (comp == 0) { --count; BSTNode* repl; if (t->lt == 0) repl = t->rt; else if (t->rt == 0) repl = t->lt; else { BSTNode* prepl = t; repl = t->lt; while (repl->rt != 0) { prepl = repl; repl = repl->rt; } if (prepl != t) { prepl->rt = repl->lt; if (prepl->rt != 0) prepl->rt->par = prepl; repl->lt = t->lt; if (repl->lt != 0) repl->lt->par = repl; } repl->rt = t->rt; if (repl->rt != 0) repl->rt->par = repl; } if (t == root) { root = repl; if (repl != 0) repl->par = 0; } else { if (t == p->lt) p->lt = repl; else p->rt = repl; if (repl != 0) repl->par = p; } delete t; return; } p = t; if (comp < 0) t = t->lt; else t = t->rt; } } void BSTSet::_kill(BSTNode* t) { if (t != 0) { _kill(t->lt); _kill(t->rt); delete t; } } BSTNode* BSTSet::_copy(BSTNode* t) { if (t == 0) return 0; else { BSTNode* u = new BSTNode(t->item, _copy(t->lt), _copy(t->rt)); if (u->lt != 0) u->lt->par = u; if (u->rt != 0) u->rt->par = u; return u; } } int BSTSet::operator == (BSTSet& y) { if (count != y.count) return 0; else { BSTNode* t = leftmost(); BSTNode* u = y.leftmost(); for (;;) { if (t == 0) return 1; else if (!EQ(t->item, u->item)) return 0; else { t = succ(t); u = y.succ(u); } } } } int BSTSet::operator <= (BSTSet& y) { if (count > y.count) return 0; else { BSTNode* t = leftmost(); BSTNode* u = y.leftmost(); for (;;) { if (t == 0) return 1; else if (u == 0) return 0; int cmp = CMP(t->item, u->item); if (cmp == 0) { t = succ(t); u = y.succ(u); } else if (cmp < 0) return 0; else u = y.succ(u); } } } // linear-time, zero space overhead binary tree rebalancing from // Stout & Warren, ``Tree rebalancing in linear space and time'' // CACM, Sept, 1986, p902. void BSTSet::balance() { if (count <= 2) return; // don't bother -- // also we assume non-null root, below // make re-attaching the root easy via trickery struct _fake_node { _fake_node *lt, *rt, *par; } fake_root; fake_root.rt = (_fake_node*)root; fake_root.par = 0; BSTNode* pseudo_root = (BSTNode*)&fake_root; // phase 1: tree-to-vine BSTNode* vine_tail = pseudo_root; BSTNode* remainder = root; while (remainder != 0) { if (remainder->lt == 0) { vine_tail = remainder; remainder = remainder->rt; } else { BSTNode* tmp = remainder->lt; remainder->lt = tmp->rt; if (remainder->lt != 0) remainder->lt->par = remainder; tmp->rt = remainder; remainder->par = tmp; vine_tail->rt = remainder = tmp; } } // phase 2: vine-to-tree // Uses the slightly simpler version adapted from // Day ``Balancing a binary tree'' Computer Journal, Nov. 1976, // since it's not generally important whether the `stray' leaves are // on the left or on the right. unsigned int spines = count - 1; while (spines > 1) { int compressions = spines >> 1; // compress every other node spines -= compressions + 1; // halve for next time BSTNode* scanner = pseudo_root; while (compressions-- > 0) { BSTNode* child = scanner->rt; BSTNode* grandchild = child->rt; scanner->rt = grandchild; grandchild->par = scanner; child->rt = grandchild->lt; if (child->rt != 0) child->rt->par = child; grandchild->lt = child; child->par = grandchild; scanner = grandchild; } } root = pseudo_root->rt; root->par = 0; } int BSTSet::OK() { int v = 1; if (root == 0) v = count == 0; else { int n = 1; BSTNode* trail = leftmost(); BSTNode* t = succ(trail); while (t != 0) { ++n; v &= CMP(trail->item, t->item) < 0; trail = t; t = succ(t); } v &= n == count; } if (!v) error("invariant failure"); return v; } 0707070000020176751004440000020000020000011114110460564776100002600000006471g++-include/BSTSet.hP// 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 _BSTSet_h #pragma once #define _BSTSet_h 1 #include ".Set.h" #ifndef _BSTNode #define _BSTNode 1 struct BSTNode { BSTNode* lt; BSTNode* rt; BSTNode* par; item; BSTNode( h, BSTNode* l=0, BSTNode* r=0, BSTNode* p = 0); ~BSTNode(); }; inline BSTNode::BSTNode( h, BSTNode* l=0, BSTNode* r=0, BSTNode* p = 0) { item = h; lt = l; rt = r; par = p; } inline BSTNode::~BSTNode() {} typedef BSTNode* BSTNodePtr; #endif class BSTSet : public Set { protected: BSTNode* root; BSTNode* leftmost(); BSTNode* rightmost(); BSTNode* pred(BSTNode* t); BSTNode* succ(BSTNode* t); void _kill(BSTNode* t); BSTNode* _copy(BSTNode* t); public: BSTSet(); BSTSet(BSTSet& a); ~BSTSet(); 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); int operator == (BSTSet& b); int operator != (BSTSet& b); int operator <= (BSTSet& b); void balance(); int OK(); }; inline BSTSet::~BSTSet() { _kill(root); } inline BSTSet::BSTSet() { root = 0; count = 0; } inline BSTSet::BSTSet(BSTSet& a) { count = a.count; root = _copy(a.root); } inline int BSTSet::operator != (BSTSet& b) { return ! (*this == b); } inline Pix BSTSet::first() { return Pix(leftmost()); } inline Pix BSTSet::last() { return Pix(rightmost()); } inline void BSTSet::next(Pix& i) { if (i != 0) i = Pix(succ((BSTNode*)i)); } inline void BSTSet::prev(Pix& i) { if (i != 0) i = Pix(pred((BSTNode*)i)); } inline & BSTSet::operator () (Pix i) { if (i == 0) error("null Pix"); return ((BSTNode*)i)->item; } inline void BSTSet::clear() { _kill(root); count = 0; root = 0; } inline int BSTSet::contains( key) { return seek(key) != 0; } #endif 0707070000020176761004440000020000020000011634400460564776300002400000003235g++-include/Bag.ccP// 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. */ #include #include ".Bag.h" // error handling void Bag::error(const char* msg) { (*lib_error_handler)("Bag", msg); } Pix Bag::seek( item, Pix i = 0) { if (i == 0) i = first(); else next(i); for (;i != 0 && (!(EQ((*this)(i), item))); next(i)); return i; } int Bag::owns(Pix p) { if (p == 0) return 0; for (Pix i = first(); i != 0; next(i)) if (i == p) return 1; return 0; } void Bag::remove( item) { int i = nof(item); while (i-- > 0) del(item); } int Bag::nof( item) { int n = 0; for (Pix p = first(); p; next(p)) if (EQ((*this)(p), item)) ++n; return n; } void Bag::clear() { Pix i = first(); while (i != 0) { del((*this)(i)); i = first(); } } 0707070000020176771004440000020000020000011602050460564776500002300000004406g++-include/Bag.hP// 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 #pragma once #define _Bag_h 1 #include #include ".defs.h" class Bag { protected: int count; public: 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 }; inline int Bag::length() { return count; } inline int Bag::empty() { return count == 0; } inline int Bag::contains( item) { return seek(item) != 0; } #endif 0707070000020177001004440000020000020000011034050460564776700002600000010453g++-include/CHBag.ccP// 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. */ #include ".CHBag.h" // The nodes are linked together serially via a version // of a trick used in some vtables: odd pointers are // actually links to the next table entry. // Not terrible, but not wonderful either static inline int goodCHptr(CHNode* t) { return ((((unsigned)t) & 1) == 0); } static inline CHNode* index_to_CHptr(int i) { return (CHNode*)((i << 1) + 1); } static inline int CHptr_to_index(CHNode* t) { return ( ((unsigned) t) >> 1); } CHBag::CHBag(unsigned int sz = DEFAULT_INITIAL_CAPACITY) { tab = (CHNode**)(new CHNodePtr[size = sz]); for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); count = 0; } CHBag::CHBag(CHBag& a) { tab = (CHNode**)(new CHNodePtr[size = a.size]); for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); count = 0; for (Pix p = a.first(); p; a.next(p)) add(a(p)); } Pix CHBag::seek( key, Pix i = 0) { CHNode* p = (CHNode*)i; if (p == 0 || !EQ(p->hd, key)) { unsigned int h = HASH(key) % size; for (CHNode* t = tab[h]; goodCHptr(t); t = t->tl) if (EQ(key, t->hd)) return Pix(t); } else { for (p = p->tl; goodCHptr(p); p = p->tl) if (EQ(p->hd, key)) return Pix(p); } return 0; } int CHBag::nof( key) { int n = 0; unsigned int h = HASH(key) % size; for (CHNode* t = tab[h]; goodCHptr(t); t = t->tl) if (EQ(key, t->hd)) ++n; return n; } Pix CHBag::add( item) { unsigned int h = HASH(item) % size; CHNode* t = new CHNode(item); t->tl = tab[h]; tab[h] = t; ++count; return Pix(t); } void CHBag::del( key) { unsigned int h = HASH(key) % size; CHNode* t = tab[h]; CHNode* trail = t; while (goodCHptr(t)) { if (EQ(key, t->hd)) { if (trail == t) tab[h] = t->tl; else trail->tl = t->tl; delete t; --count; return; } trail = t; t = t->tl; } } void CHBag::remove( key) { unsigned int h = HASH(key) % size; CHNode* t = tab[h]; CHNode* trail = t; while (goodCHptr(t)) { if (EQ(key, t->hd)) { --count; if (trail == t) { tab[h] = t->tl; delete t; t = trail = tab[h]; } else { trail->tl = t->tl; delete t; t = trail->tl; } } else { trail = t; t = t->tl; } } } void CHBag::clear() { for (unsigned int i = 0; i < size; ++i) { CHNode* p = tab[i]; tab[i] = index_to_CHptr(i+1); while (goodCHptr(p)) { CHNode* nxt = p->tl; delete(p); p = nxt; } } count = 0; } Pix CHBag::first() { for (unsigned int i = 0; i < size; ++i) if (goodCHptr(tab[i])) return Pix(tab[i]); return 0; } void CHBag::next(Pix& p) { if (p == 0) return; CHNode* t = ((CHNode*)p)->tl; if (goodCHptr(t)) p = Pix(t); else { for (unsigned int i = CHptr_to_index(t); i < size; ++i) { if (goodCHptr(tab[i])) { p = Pix(tab[i]); return; } } p = 0; } } int CHBag::OK() { int v = tab != 0; int n = 0; for (unsigned int i = 0; i < size; ++i) { for (CHNode* p = tab[i]; goodCHptr(p); p = p->tl) ++n; v &= CHptr_to_index(p) == i + 1; } v &= count == n; if (!v) error("invariant failure"); return v; } 0707070000020177011004440000020000020000011600050460564777100002500000004366g++-include/CHBag.hP// 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 #pragma once #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(); }; inline CHNode::CHNode() {} inline CHNode::CHNode( h, CHNode* t = 0) { hd = h; tl = t; } inline CHNode::~CHNode() {} 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(); }; 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 0707070000020177021004440000020000020000010467010460564777300002600000007264g++-include/CHMap.ccP// 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. */ #include "..CHMap.h" // The nodes are linked together serially via a version // of a trick used in some vtables: odd pointers are // actually links to the next table entry. // Not terrible, but not wonderful either static inline int goodCHptr(CHNode* t) { return ((((unsigned)t) & 1) == 0); } static inline CHNode* index_to_CHptr(int i) { return (CHNode*)((i << 1) + 1); } static inline int CHptr_to_index(CHNode* t) { return ( ((unsigned) t) >> 1); } CHMap::CHMap( dflt, unsigned int sz = DEFAULT_INITIAL_CAPACITY) :(dflt) { tab = (CHNode**)(new CHNodePtr[size = sz]); for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); count = 0; } CHMap::CHMap(CHMap& a) :(a.def) { tab = (CHNode**)(new CHNodePtr[size = a.size]); for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); count = 0; for (Pix p = a.first(); p; a.next(p)) (*this)[a.key(p)] = a.contents(p); } Pix CHMap::seek( key) { unsigned int h = HASH(key) % size; for (CHNode* t = tab[h]; goodCHptr(t); t = t->tl) if (EQ(key, t->hd)) return Pix(t); return 0; } & CHMap::operator []( item) { unsigned int h = HASH(item) % size; for (CHNode* t = tab[h]; goodCHptr(t); t = t->tl) if (EQ(item, t->hd)) return t->cont; t = new CHNode(item, def, tab[h]); tab[h] = t; ++count; return t->cont; } void CHMap::del( key) { unsigned int h = HASH(key) % size; CHNode* t = tab[h]; CHNode* trail = t; while (goodCHptr(t)) { if (EQ(key, t->hd)) { if (trail == t) tab[h] = t->tl; else trail->tl = t->tl; delete t; --count; return; } trail = t; t = t->tl; } } void CHMap::clear() { for (unsigned int i = 0; i < size; ++i) { CHNode* p = tab[i]; tab[i] = index_to_CHptr(i+1); while (goodCHptr(p)) { CHNode* nxt = p->tl; delete(p); p = nxt; } } count = 0; } Pix CHMap::first() { for (unsigned int i = 0; i < size; ++i) if (goodCHptr(tab[i])) return Pix(tab[i]); return 0; } void CHMap::next(Pix& p) { CHNode* t = ((CHNode*)p)->tl; if (goodCHptr(t)) p = Pix(t); else { for (unsigned int i = CHptr_to_index(t); i < size; ++i) { if (goodCHptr(tab[i])) { p = Pix(tab[i]); return; } } p = 0; } } int CHMap::OK() { int v = tab != 0; int n = 0; for (unsigned int i = 0; i < size; ++i) { for (CHNode* p = tab[i]; goodCHptr(p); p = p->tl) ++n; v &= CHptr_to_index(p) == i + 1; } v &= count == n; if (!v) error("invariant failure"); return v; } 0707070000020177031004440000020000020000011574770460564777600002500000004677g++-include/CHMap.hP// 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 _CHMap_h #pragma once #define _CHMap_h 1 #include "..Map.h" #ifndef _CHNode_h #define _CHNode_h 1 struct CHNode { CHNode* tl; hd; cont; CHNode(); CHNode( h, c, CHNode* t = 0); ~CHNode(); }; inline CHNode::CHNode() {} inline CHNode::CHNode( h, c, CHNode* t = 0) : hd(h), cont(c), tl(t) {} inline CHNode::~CHNode() {} typedef CHNode* CHNodePtr; #endif class CHMap : public Map { protected: CHNode** tab; unsigned int size; public: CHMap( dflt,unsigned int sz=DEFAULT_INITIAL_CAPACITY); CHMap(CHMap& a); ~CHMap(); & 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(); int OK(); }; inline CHMap::~CHMap() { clear(); delete tab; } inline int CHMap::contains( key) { return seek(key) != 0; } inline & CHMap::key(Pix p) { if (p == 0) error("null Pix"); return ((CHNode*)p)->hd; } inline & CHMap::contents(Pix p) { if (p == 0) error("null Pix"); return ((CHNode*)p)->cont; } #endif 0707070000020177041004440000020000020000010350310460565000000002600000013773g++-include/CHSet.ccP// 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. */ #include ".CHSet.h" // A CHSet is implemented as an array (tab) of buckets, each of which // contains a pointer to a list of CHNodes. Each node contains a // pointer to the next node in the list, and a pointer to the . // The end of the list is marked by a next node pointer which is odd // when considered as an integer (least significant bit = 1). The // assumption is that CHNodes will all begin on even addresses. If // the odd pointer is right-shifted by one bit, it becomes the index // within the tab array of the next bucket (that is, bucket i has // next bucket pointer 2*(i+1)+1). // The bucket pointers are initialized by the constructor and // used to support the next(Pix&) method. // This implementation is not portable to machines with different // pointer and integer sizes, or on which CHNodes might be aligned on // odd byte boundaries, but allows the same pointer to be used for // chaining within a bucket and to the next bucket. static inline int goodCHptr(CHNode* t) { return ((((unsigned)t) & 1) == 0); } static inline CHNode* index_to_CHptr(int i) { return (CHNode*)((i << 1) + 1); } static inline int CHptr_to_index(CHNode* t) { return ( ((unsigned) t) >> 1); } CHSet::CHSet(unsigned int sz = DEFAULT_INITIAL_CAPACITY) { tab = (CHNode**)(new CHNodePtr[size = sz]); for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); count = 0; } CHSet::CHSet(CHSet& a) { tab = (CHNode**)(new CHNodePtr[size = a.size]); for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1); count = 0; for (Pix p = a.first(); p; a.next(p)) add(a(p)); } Pix CHSet::seek( key) { unsigned int h = HASH(key) % size; for (CHNode* t = tab[h]; goodCHptr(t); t = t->tl) if (EQ(key, t->hd)) return Pix(t); return 0; } Pix CHSet::add( item) { unsigned int h = HASH(item) % size; for (CHNode* t = tab[h]; goodCHptr(t); t = t->tl) if (EQ(item, t->hd)) return Pix(t); ++count; t = new CHNode(item, tab[h]); tab[h] = t; return Pix(t); } void CHSet::del( key) { unsigned int h = HASH(key) % size; CHNode* t = tab[h]; CHNode* trail = t; while (goodCHptr(t)) { if (EQ(key, t->hd)) { if (trail == t) tab[h] = t->tl; else trail->tl = t->tl; delete t; --count; return; } trail = t; t = t->tl; } } void CHSet::clear() { for (unsigned int i = 0; i < size; ++i) { CHNode* p = tab[i]; tab[i] = index_to_CHptr(i+1); while (goodCHptr(p)) { CHNode* nxt = p->tl; delete(p); p = nxt; } } count = 0; } Pix CHSet::first() { for (unsigned int i = 0; i < size; ++i) if (goodCHptr(tab[i])) return Pix(tab[i]); return 0; } void CHSet::next(Pix& p) { if (p == 0) return; CHNode* t = ((CHNode*)p)->tl; if (goodCHptr(t)) p = Pix(t); else { for (unsigned int i = CHptr_to_index(t); i < size; ++i) { if (goodCHptr(tab[i])) { p = Pix(tab[i]); return; } } p = 0; } } int CHSet::operator == (CHSet& b) { if (count != b.count) return 0; else { CHNode* p; for (unsigned int i = 0; i < size; ++i) for (p = tab[i]; goodCHptr(p); p = p->tl) if (b.seek(p->hd) == 0) return 0; for (i = 0; i < b.size; ++i) for (p = b.tab[i]; goodCHptr(p); p = p->tl) if (seek(p->hd) == 0) return 0; return 1; } } int CHSet::operator <= (CHSet& b) { if (count > b.count) return 0; else { for (unsigned int i = 0; i < size; ++i) for (CHNode* p = tab[i]; goodCHptr(p); p = p->tl) if (b.seek(p->hd) == 0) return 0; return 1; } } void CHSet::operator |= (CHSet& b) { if (&b == this || b.count == 0) return; for (unsigned int i = 0; i < b.size; ++i) for (CHNode* p = b.tab[i]; goodCHptr(p); p = p->tl) add(p->hd); } void CHSet::operator &= (CHSet& b) { for (unsigned int i = 0; i < size; ++i) { CHNode* t = tab[i]; CHNode* trail = t; while (goodCHptr(t)) { CHNode* nxt = t->tl; if (b.seek(t->hd) == 0) { if (trail == tab[i]) trail = tab[i] = nxt; else trail->tl = nxt; delete t; --count; } else trail = t; t = nxt; } } } void CHSet::operator -= (CHSet& b) { for (unsigned int i = 0; i < size; ++i) { CHNode* t = tab[i]; CHNode* trail = t; while (goodCHptr(t)) { CHNode* nxt = t->tl; if (b.seek(t->hd) != 0) { if (trail == tab[i]) trail = tab[i] = nxt; else trail->tl = nxt; delete t; --count; } else trail = t; t = nxt; } } } int CHSet::OK() { int v = tab != 0; int n = 0; for (unsigned int i = 0; i < size; ++i) { for (CHNode* p = tab[i]; goodCHptr(p); p = p->tl) ++n; v &= CHptr_to_index(p) == i + 1; } v &= count == n; if (!v) error("invariant failure"); return v; } 0707070000020177051004440000020000020000011157360460565000200002500000004772g++-include/CHSet.hP// 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 #pragma once #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(); }; inline CHNode::CHNode() {} inline CHNode::CHNode( h, CHNode* t = 0) { hd = h; tl = t; } inline CHNode::~CHNode() {} 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(); }; 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 0707070000020177061004440000020000020000010277310460565000400002700000005001g++-include/DLDeque.hP// 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 #pragma once #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(); }; 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 0707070000020177071004440000020000020000011117340460565000600002700000012163g++-include/DLList.ccP// 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. */ #include #include #include ".DLList.h" // error handling void DLList::error(const char* msg) { (*lib_error_handler)("DLList", msg); } DLList::DLList(DLList& a) { if (a.h == 0) h = 0; else { DLListNode* p = a.h; DLListNode* t = new DLListNode(p->hd); h = t; p = p->fd; while (p != a.h) { DLListNode* n = new DLListNode(p->hd); t->fd = n; n->bk = t; t = n; p = p->fd; } t->fd = h; h->bk = t; return; } } DLList& DLList::operator = (DLList& a) { if (h != a.h) { clear(); if (a.h != 0) { DLListNode* p = a.h; DLListNode* t = new DLListNode(p->hd); h = t; p = p->fd; while (p != a.h) { DLListNode* n = new DLListNode(p->hd); t->fd = n; n->bk = t; t = n; p = p->fd; } t->fd = h; h->bk = t; } } return *this; } void DLList::clear() { if (h == 0) return; DLListNode* p = h->fd; h->fd = 0; h = 0; while (p != 0) { DLListNode* nxt = p->fd; delete(p); p = nxt; } } Pix DLList::prepend( item) { DLListNode* t = new DLListNode(item); if (h == 0) t->fd = t->bk = h = t; else { t->fd = h; t->bk = h->bk; h->bk->fd = t; h->bk = t; h = t; } return Pix(t); } Pix DLList::append( item) { DLListNode* t = new DLListNode(item); if (h == 0) t->fd = t->bk = h = t; else { t->bk = h->bk; t->bk->fd = t; t->fd = h; h->bk = t; } return Pix(t); } Pix DLList::ins_after(Pix p, item) { if (p == 0) error("null Pix"); DLListNode* u = (DLListNode*) p; DLListNode* t = new DLListNode(item, u, u->fd); u->fd->bk = t; u->fd = t; return Pix(t); } Pix DLList::ins_before(Pix p, item) { if (p == 0) error("null Pix"); DLListNode* u = (DLListNode*) p; DLListNode* t = new DLListNode(item, u->bk, u); u->bk->fd = t; u->bk = t; if (u == h) h = t; return Pix(t); } void DLList::join(DLList& b) { DLListNode* t = b.h; b.h = 0; if (h == 0) h = t; else if (t != 0) { DLListNode* l = t->bk; h->bk->fd = t; t->bk = h->bk; h->bk = l; l->fd = h; } } int DLList::owns(Pix p) { DLListNode* t = h; if (t != 0 && p != 0) { do { if (Pix(t) == p) return 1; t = t->fd; } while (t != h); } return 0; } void DLList::del(Pix& p, int dir = 1) { if (p == 0) error("null Pix"); DLListNode* t = (DLListNode*) p; if (t->fd == t) { h = 0; p = 0; } else { if (dir < 0) { if (t == h) p = 0; else p = Pix(t->bk); } else { if (t == h->bk) p = 0; else p = Pix(t->fd); } t->bk->fd = t->fd; t->fd->bk = t->bk; if (t == h) h = t->fd; } delete t; } DLList::remove_front() { if (h == 0) error("remove_front of empty list"); DLListNode* t = h; res = t->hd; if (h->fd == h) h = 0; else { h->fd->bk = h->bk; h->bk->fd = h->fd; h = h->fd; } delete t; return res; } void DLList::del_front() { if (h == 0) error("del_front of empty list"); DLListNode* t = h; if (h->fd == h) h = 0; else { h->fd->bk = h->bk; h->bk->fd = h->fd; h = h->fd; } delete t; } DLList::remove_rear() { if (h == 0) error("remove_rear of empty list"); DLListNode* t = h->bk; res = t->hd; if (h->fd == h) h = 0; else { t->fd->bk = t->bk; t->bk->fd = t->fd; } delete t; return res; } void DLList::del_rear() { if (h == 0) error("del_rear of empty list"); DLListNode* t = h->bk; if (h->fd == h) h = 0; else { t->fd->bk = t->bk; t->bk->fd = t->fd; } delete t; } int DLList::OK() { int v = 1; if (h != 0) { DLListNode* t = h; long count = MAXLONG; // Lots of chances to find h! do { count--; v &= t->bk->fd == t; v &= t->fd->bk == t; t = t->fd; } while (v && count > 0 && t != h); v &= count > 0; } if (!v) error("invariant failure"); return v; } 0707070000020177101004440000020000020000010723640460565001000002600000007424g++-include/DLList.hP// 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 #pragma once #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(); }; inline DLListNode::DLListNode() {} inline DLListNode::DLListNode( h, DLListNode* p = 0, DLListNode* n = 0) { hd = h; bk = p; fd = n; } inline DLListNode::~DLListNode() {} 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(); }; inline DLList::~DLList() { clear(); } inline DLList::DLList() { h = 0; } inline int DLList::empty() { return h == 0; } inline int DLList::length() { int l = 0; DLListNode* t = h; if (t != 0) do { ++l; t = t->fd; } while (t != h); return l; } 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 0707070000020177111004440000020000020000011217720460565001200003000000023345g++-include/SplayPQ.ccP// 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. */ #include #include #include ".SplayPQ.h" /* struct to simulate the special `null' node in the Sleater & Tarjan JACM 1985 splay tree algorithms All routines use a version of their `simple top-down' splay alg. (p 669) */ struct _dummySplayNode { SplayNode* lt; SplayNode* rt; SplayNode* par; } _dummy_null; /* traversal primitives */ SplayNode* SplayPQ::leftmost() { SplayNode* t = root; if (t != 0) while (t->lt != 0) t = t->lt; return t; } SplayNode* SplayPQ::rightmost() { SplayNode* t = root; if (t != 0) while (t->rt != 0) t = t->rt; return t; } SplayNode* SplayPQ::succ(SplayNode* t) { if (t == 0) return 0; if (t->rt != 0) { t = t->rt; while (t->lt != 0) t = t->lt; return t; } else { for (;;) { if (t->par == 0 || t == t->par->lt) return t->par; else t = t->par; } } } SplayNode* SplayPQ::pred(SplayNode* t) { if (t == 0) return 0; else if (t->lt != 0) { t = t->lt; while (t->rt != 0) t = t->rt; return t; } else { for (;;) { if (t->par == 0 || t == t->par->rt) return t->par; else t = t->par; } } } Pix SplayPQ::seek( key) { SplayNode* t = root; if (t == 0) return 0; int comp = CMP(key, t->item); if (comp == 0) return Pix(t); SplayNode* dummy = (SplayNode*)(&_dummy_null); SplayNode* l = dummy; SplayNode* r = dummy; dummy->rt = dummy->lt = dummy->par = 0; while (comp != 0) { if (comp > 0) { SplayNode* tr = t->rt; if (tr == 0) break; else { comp = CMP(key, tr->item); if (comp <= 0 || tr->rt == 0) { l->rt = t; t->par = l; l = t; t = tr; if (comp >= 0) break; } else { if ((t->rt = tr->lt) != 0) t->rt->par = t; tr->lt = t; t->par = tr; l->rt = tr; tr->par = l; l = tr; t = tr->rt; comp = CMP(key, t->item); } } } else { SplayNode* tl = t->lt; if (tl == 0) break; else { comp = CMP(key, tl->item); if (comp >= 0 || tl->lt == 0) { r->lt = t; t->par = r; r = t; t = tl; if (comp <= 0) break; } else { if ((t->lt = tl->rt) != 0) t->lt->par = t; tl->rt = t; t->par = tl; r->lt = tl; tl->par = r; r = tl; t = tl->lt; comp = CMP(key, t->item); } } } } if ((r->lt = t->rt) != 0) r->lt->par = r; if ((l->rt = t->lt) != 0) l->rt->par = l; if ((t->lt = dummy->rt) != 0) t->lt->par = t; if ((t->rt = dummy->lt) != 0) t->rt->par = t; t->par = 0; root = t; return (comp == 0) ? Pix(t) : 0; } Pix SplayPQ::enq( item) { ++count; SplayNode* newnode = new SplayNode(item); SplayNode* t = root; if (t == 0) { root = newnode; return Pix(root); } int comp = CMP(item, t->item); SplayNode* dummy = (SplayNode*)(&_dummy_null); SplayNode* l = dummy; SplayNode* r = dummy; dummy->rt = dummy->lt = dummy->par = 0; int done = 0; while (!done) { if (comp >= 0) { SplayNode* tr = t->rt; if (tr == 0) { tr = newnode; comp = 0; done = 1; } else comp = CMP(item, tr->item); if (comp <= 0) { l->rt = t; t->par = l; l = t; t = tr; } else { SplayNode* trr = tr->rt; if (trr == 0) { trr = newnode; comp = 0; done = 1; } else comp = CMP(item, trr->item); if ((t->rt = tr->lt) != 0) t->rt->par = t; tr->lt = t; t->par = tr; l->rt = tr; tr->par = l; l = tr; t = trr; } } else { SplayNode* tl = t->lt; if (tl == 0) { tl = newnode; comp = 0; done = 1; } else comp = CMP(item, tl->item); if (comp >= 0) { r->lt = t; t->par = r; r = t; t = tl; } else { SplayNode* tll = tl->lt; if (tll == 0) { tll = newnode; comp = 0; done = 1; } else comp = CMP(item, tll->item); if ((t->lt = tl->rt) != 0) t->lt->par = t; tl->rt = t; t->par = tl; r->lt = tl; tl->par = r; r = tl; t = tll; } } } if ((r->lt = t->rt) != 0) r->lt->par = r; if ((l->rt = t->lt) != 0) l->rt->par = l; if ((t->lt = dummy->rt) != 0) t->lt->par = t; if ((t->rt = dummy->lt) != 0) t->rt->par = t; t->par = 0; root = t; return Pix(root); } void SplayPQ::del(Pix pix) { SplayNode* t = (SplayNode*)pix; if (t == 0) return; SplayNode* p = t->par; --count; if (t->rt == 0) { if (t == root) { if ((root = t->lt) != 0) root->par = 0; } else if (t == p->lt) { if ((p->lt = t->lt) != 0) p->lt->par = p; } else if ((p->rt = t->lt) != 0) p->rt->par = p; } else { SplayNode* r = t->rt; SplayNode* l = r->lt; for(;;) { if (l == 0) { if (t == root) { root = r; r->par = 0; } else if (t == p->lt) { p->lt = r; r->par = p; } else { p->rt = r; r->par = p; } if ((r->lt = t->lt) != 0) r->lt->par = r; break; } else { if ((r->lt = l->rt) != 0) r->lt->par = r; l->rt = r; r->par = l; r = l; l = l->lt; } } } delete t; } & SplayPQ::front() { if (root == 0) error ("min: empty tree\n"); // else { SplayNode* t = root; SplayNode* l = root->lt; for(;;) { if (l == 0) { root = t; root->par = 0; return root->item; } else { if ((t->lt = l->rt) != 0) t->lt->par = t; l->rt = t; t->par = l; t = l; l = l->lt; } } } } void SplayPQ::del_front() { if (root != 0) { --count; SplayNode* t = root; SplayNode* l = root->lt; if (l == 0) { if ((root = t->rt) != 0) root->par = 0; delete t; } else { for(;;) { SplayNode* ll = l->lt; if (ll == 0) { if ((t->lt = l->rt) != 0) t->lt->par = t; delete l; break; } else { SplayNode* lll = ll->lt; if (lll == 0) { if ((l->lt = ll->rt) != 0) l->lt->par = l; delete ll; break; } else { t->lt = ll; ll->par = t; if ((l->lt = ll->rt) != 0) l->lt->par = l; ll->rt = l; l->par = ll; t = ll; l = lll; } } } } } } SplayPQ::deq() { if (root == 0) error("deq: empty tree"); // else { --count; SplayNode* t = root; SplayNode* l = root->lt; if (l == 0) { if ((root = t->rt) != 0) root->par = 0; res = t->item; delete t; return res; } else { for(;;) { SplayNode* ll = l->lt; if (ll == 0) { if ((t->lt = l->rt) != 0) t->lt->par = t; res = l->item; delete l; return res; } else { SplayNode* lll = ll->lt; if (lll == 0) { if ((l->lt = ll->rt) != 0) l->lt->par = l; res = ll->item; delete ll; return res; } else { t->lt = ll; ll->par = t; if ((l->lt = ll->rt) != 0) l->lt->par = l; ll->rt = l; l->par = ll; t = ll; l = lll; } } } } } } void SplayPQ::_kill(SplayNode* t) { if (t != 0) { _kill(t->lt); _kill(t->rt); delete t; } } SplayNode* SplayPQ::_copy(SplayNode* t) { if (t != 0) { SplayNode* l = _copy(t->lt); SplayNode* r = _copy(t->rt); SplayNode* x = new SplayNode(t->item, l, r); if (l != 0) l->par = x; if (r != 0) r->par = x; return x; } else return 0; } int SplayPQ::OK() { int v = 1; if (root == 0) v = count == 0; else { int n = 1; SplayNode* trail = leftmost(); SplayNode* t = succ(trail); while (t != 0) { ++n; v &= CMP(trail->item, t->item) < 0; trail = t; t = succ(t); } v &= n == count; } if (!v) error("invariant failure"); return v; } 0707070000020177121004440000020000020000011430740460565001400002500000003576g++-include/Deque.hP// 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 #pragma once #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*); }; inline Deque::Deque() {} inline Deque::~Deque() {} inline void Deque::error(const char* msg) { (*lib_error_handler)("Deque", msg); } #endif 0707070000020177131004440000020000020000011171500460565001600002700000004602g++-include/FPQueue.hP// 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 _FPQueue_h #pragma once #define _FPQueue_h #include ".FPlex.h" #include ".Queue.h" class FPQueue : public Queue { FPlex p; public: FPQueue(int chunksize = DEFAULT_PLEX_CHUNK_SIZE); FPQueue(const FPQueue& q); ~FPQueue(); void operator = (const FPQueue&); void enq( item); deq(); & front(); void del_front(); void clear(); int empty(); int full(); int length(); int OK(); }; inline FPQueue::FPQueue(int chunksize = DEFAULT_PLEX_CHUNK_SIZE) : p(chunksize) {} inline FPQueue::FPQueue(const FPQueue& q) : p(q.p) {} inline FPQueue::~FPQueue() {} inline void FPQueue::enq(item) { p.add_high(item); } inline FPQueue::deq() { res = p.low_element(); p.del_low(); return res; } inline & FPQueue::front() { return p.low_element(); } inline void FPQueue::del_front() { p.del_low(); } inline void FPQueue::operator =(const FPQueue& s) { p = s.p; } inline int FPQueue::empty() { return p.empty(); } inline int FPQueue::full() { return p.full(); } inline int FPQueue::length() { return p.length(); } inline int FPQueue::OK() { return p.OK(); } inline void FPQueue::clear() { p.clear(); } #endif 0707070000020177141004440000020000020000011552000460565002000002700000004613g++-include/FPStack.hP// 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 _FPStack_h #pragma once #define _FPStack_h #include ".FPlex.h" #include ".Stack.h" class FPStack : public Stack { FPlex p; public: FPStack(int chunksize = DEFAULT_PLEX_CHUNK_SIZE); FPStack(const FPStack& s); ~FPStack(); void operator = (const FPStack&); void push( item); pop(); & top(); void del_top(); int empty(); int full(); int length(); void clear(); int OK(); }; inline FPStack::FPStack(int chunksize = DEFAULT_PLEX_CHUNK_SIZE) : p(chunksize) {} inline FPStack::FPStack(const FPStack& s) : p(s.p) {} inline FPStack::~FPStack() {} inline void FPStack::push(item) { p.add_high(item); } inline FPStack::pop() { res = p.high_element(); p.del_high(); return res; } inline & FPStack::top() { return p.high_element(); } inline void FPStack::del_top() { p.del_high(); } inline void FPStack::operator =(const FPStack& s) { p = s.p; } inline int FPStack::empty() { return p.empty(); } inline int FPStack::full() { return p.full(); } inline int FPStack::length() { return p.length(); } inline int FPStack::OK() { return p.OK(); } inline void FPStack::clear() { p.clear(); } #endif 0707070000020177151004440000020000020000011326060460565002300002600000010176g++-include/FPlex.ccP// 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. */ #include ".FPlex.h" FPlex:: FPlex() { lo = fnc = 0; csize = DEFAULT_INITIAL_CAPACITY; * data = new [csize]; hd = new IChunk(data, lo, lo, fnc, csize); } FPlex:: FPlex(int maxsize) { if (maxsize == 0) error("invalid constructor specification"); lo = fnc = 0; if (maxsize > 0) { csize = maxsize; * data = new [csize]; hd = new IChunk(data, lo, lo, fnc, csize); } else { csize = -maxsize; * data = new [csize]; hd = new IChunk(data, maxsize, lo, fnc, fnc); } } FPlex:: FPlex(int l, int maxsize) { if (maxsize == 0) error("invalid constructor specification"); lo = fnc = l; if (maxsize > 0) { csize = maxsize; * data = new [csize]; hd = new IChunk(data, lo, lo, fnc, csize+lo); } else { csize = -maxsize; * data = new [csize]; hd = new IChunk(data, maxsize+lo, lo, fnc, fnc); } } FPlex:: FPlex(int l, int hi, const initval, int maxsize = 0) { lo = l; fnc = hi + 1; if (maxsize >= 0) { csize = maxsize; if (csize < fnc - lo) csize = fnc - lo; * data = new [csize]; hd = new IChunk(data, lo, lo, fnc, csize); } else { csize = -maxsize; if (csize < fnc - lo) csize = fnc - lo; * data = new [csize]; hd = new IChunk(data, -csize, lo, fnc, fnc); } fill(initval); } FPlex::FPlex(const FPlex& a) { lo = a.lo; fnc = a.fnc; csize = fnc - lo; if (csize < a.csize) csize = a.csize; * data = new [csize]; hd = new IChunk(data, lo, lo, fnc, lo+csize); for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i]; } void FPlex::operator= (const FPlex& a) { if (&a != this) { del_chunk(hd); lo = a.lo; fnc = a.fnc; csize = fnc - lo; if (csize < a.csize) csize = a.csize; * data = new [csize]; hd = new IChunk(data, lo, lo, fnc, lo+csize); for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i]; } } void FPlex::append (const FPlex& a) { for (int i = a.low(); i < a.fence(); a.next(i)) add_high(a[i]); } void FPlex::prepend (const FPlex& a) { for (int i = a.high(); i > a.ecnef(); a.prev(i)) add_low(a[i]); } void FPlex::reverse() { tmp; int l = lo; int h = fnc - 1; while (l < h) { tmp = (*this)[l]; (*this)[l] = (*this)[h]; (*this)[h] = tmp; next(l); prev(h); } } void FPlex::fill(const x) { for (int i = lo; i < fnc; ++i) (*this)[i] = x; } void FPlex::fill(const x, int lo, int hi) { for (int i = lo; i <= hi; ++i) (*this)[i] = x; } void FPlex::clear() { if (fnc != lo) { hd->clear(lo); fnc = lo; } } int FPlex::OK () const { int v = hd != 0; // hd exists v &= hd->IChunk::OK(); // and is OK v &= fnc - lo <= hd->size(); // and has enough space v &= lo <= fnc; // plex indices consistent v &= lo == hd->low_index(); // and match those v &= fnc == hd->fence_index(); // of chunk v &= one_chunk(); // and only one chunk if (!v) error("invariant failure"); return v; } 0707070000020177161004440000020000020000010531120460565002500002500000014116g++-include/FPlex.hP// 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 #pragma once #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; }; 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 0707070000020177171004440000020000020000011124410460565003000002500000037767g++-include/List.ccP// 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. */ #include #include ".List.h" ListNode NilListNode; class init_NilListNode { public: inline init_NilListNode() { NilListNode.tl = &NilListNode; NilListNode.ref = -1; } }; static init_NilListNode NilListNode_initializer; int operator == (List& x, List& y) { ListNode* a = x.P; ListNode* b = y.P; for (;;) { if (a == &NilListNode) return b == &NilListNode; else if (b == &NilListNode) return 0; else if (a->hd == b->hd) { a = a->tl; b = b->tl; } else return 0; } } void List::apply(Procedure f) { for(ListNode* p = P; p != &NilListNode; p = p->tl) (*f)((p->hd)); } void List::subst( old, repl) { for(ListNode* p = P; p != &NilListNode; p = p->tl) if (p->hd == old) p->hd = repl; } List::reduce(Combiner f, base) { r = base; for(ListNode* p = P; p != &NilListNode; p = p->tl) r = (*f)(r, (p->hd)); return r; } int List::position( targ) { int l = 0; ListNode* p = P; for (;;) { if (p == &NilListNode) return -1; else if (p->hd == targ) return l; else { ++l; p = p->tl; } } } int List::contains( targ) { ListNode* p = P; for (;;) { if (p == &NilListNode) return 0; else if (p->hd == targ) return 1; else p = p->tl; } } List List::find( targ) { for (ListNode* p = P; p != &NilListNode && !(p->hd == targ); p=p->tl); reference(p); return List(p); } Pix List::seek( targ) { ListNode* p = P; for (;;) { if (p == &NilListNode) return 0; else if (p->hd == targ) return Pix(p); else p = p->tl; } } int List::owns(Pix i) { ListNode* p = P; for (;;) { if (p == &NilListNode) return 0; else if (Pix(p) == i) return 1; else p = p->tl; } } List List::find(List& target) { ListNode* targ = target.P; if (targ == &NilListNode) return List(targ); ListNode* p = P; while (p != &NilListNode) { if (p->hd == targ->hd) { ListNode* a = p->tl; ListNode* t = targ->tl; for(;;) { if (t == &NilListNode) { reference(p); return List(p); } else if (a == &NilListNode || !(a->hd == t->hd)) break; else { a = a->tl; t = t->tl; } } } p = p->tl; } return List(&NilListNode); } int List::contains(List& target) { ListNode* targ = target.P; if (targ == &NilListNode) return 0; ListNode* p = P; while (p != &NilListNode) { if (p->hd == targ->hd) { ListNode* a = p->tl; ListNode* t = targ->tl; for(;;) { if (t == &NilListNode) return 1; else if (a == &NilListNode || !(a->hd == t->hd)) break; else { a = a->tl; t = t->tl; } } } p = p->tl; } return 0; } void List::del( targ) { ListNode* h = P; for (;;) { if (h == &NilListNode) { P = h; return; } else if (h->hd == targ) { ListNode* nxt = h->tl; reference(nxt); dereference(h); h = nxt; } else break; } ListNode* trail = h; ListNode* p = h->tl; while (p != &NilListNode) { if (p->hd == targ) { ListNode* nxt = p->tl; reference(nxt); dereference(p); trail->tl = nxt; p = nxt; } else { trail = p; p = p->tl; } } P = h; } void List::del(Predicate f) { ListNode* h = P; for (;;) { if (h == &NilListNode) { P = h; return; } else if ((*f)(h->hd)) { ListNode* nxt = h->tl; reference(nxt); dereference(h); h = nxt; } else break; } ListNode* trail = h; ListNode* p = h->tl; while (p != &NilListNode) { if ((*f)(p->hd)) { ListNode* nxt = p->tl; reference(nxt); dereference(p); trail->tl = nxt; p = nxt; } else { trail = p; p = p->tl; } } P = h; } void List::select(Predicate f) { ListNode* h = P; for (;;) { if (h == &NilListNode) { P = h; return; } else if (!(*f)(h->hd)) { ListNode* nxt = h->tl; reference(nxt); dereference(h); h = nxt; } else break; } ListNode* trail = h; ListNode* p = h->tl; while (p != &NilListNode) { if (!(*f)(p->hd)) { ListNode* nxt = p->tl; reference(nxt); dereference(p); trail->tl = nxt; p = nxt; } else { trail = p; p = p->tl; } } P = h; } void List::reverse() { ListNode* l = &NilListNode; ListNode* p = P; while (p != &NilListNode) { ListNode* nxt = p->tl; p->tl = l; l = p; p = nxt; } P = l; } List copy(List& x) { ListNode* a = x.P; if (a == &NilListNode) return List(a); else { ListNode* h = newListNode(a->hd); ListNode* trail = h; for(a = a->tl; a != &NilListNode; a = a->tl) { ListNode* n = newListNode(a->hd); trail->tl = n; trail = n; } trail->tl = &NilListNode; return List(h); } } List subst( old, repl, List& x) { ListNode* a = x.P; if (a == &NilListNode) return List(a); else { ListNode* h = new ListNode; h->ref = 1; if (a->hd == old) h->hd = repl; else h->hd = a->hd; ListNode* trail = h; for(a = a->tl; a != &NilListNode; a = a->tl) { ListNode* n = new ListNode; n->ref = 1; if (a->hd == old) n->hd = repl; else n->hd = a->hd; trail->tl = n; trail = n; } trail->tl = &NilListNode; return List(h); } } List combine(Combiner f, List& x, List& y) { ListNode* a = x.P; ListNode* b = y.P; if (a == &NilListNode || b == &NilListNode) return List(&NilListNode); else { ListNode* h = newListNode((*f)(a->hd, b->hd)); ListNode* trail = h; a = a->tl; b = b->tl; while (a != &NilListNode && b != &NilListNode) { ListNode* n = newListNode((*f)(a->hd, b->hd)); trail->tl = n; trail = n; a = a->tl; b = b->tl; } trail->tl = &NilListNode; return List(h); } } List reverse(List& x) { ListNode* a = x.P; if (a == &NilListNode) return List(a); else { ListNode* l = newListNode(a->hd); l->tl = &NilListNode; for(a = a->tl; a != &NilListNode; a = a->tl) { ListNode* n = newListNode(a->hd); n->tl = l; l = n; } return List(l); } } List append(List& x, List& y) { ListNode* a = x.P; ListNode* b = y.P; reference(b); if (a != &NilListNode) { ListNode* h = newListNode(a->hd); ListNode* trail = h; for(a = a->tl; a != &NilListNode; a = a->tl) { ListNode* n = newListNode(a->hd); trail->tl = n; trail = n; } trail->tl = b; return List(h); } else return List(b); } void List::prepend(List& y) { ListNode* b = y.P; if (b != &NilListNode) { ListNode* h = newListNode(b->hd); ListNode* trail = h; for(b = b->tl; b != &NilListNode; b = b->tl) { ListNode* n = newListNode(b->hd); trail->tl = n; trail = n; } trail->tl = P; P = h; } } List concat(List& x, List& y) { ListNode* a = x.P; ListNode* b = y.P; if (a != &NilListNode) { ListNode* h = newListNode(a->hd); ListNode* trail = h; for(a = a->tl; a != &NilListNode; a = a->tl) { ListNode* n = newListNode(a->hd); trail->tl = n; trail = n; }; for(;b != &NilListNode; b = b->tl) { ListNode* n = newListNode(b->hd); trail->tl = n; trail = n; } trail->tl = &NilListNode; return List(h); } else if (b != &NilListNode) { ListNode* h = newListNode(b->hd); ListNode* trail = h; for(b = b->tl; b != &NilListNode; b = b->tl) { ListNode* n = newListNode(b->hd); trail->tl = n; trail = n; } trail->tl = &NilListNode; return List(h); } else return List(&NilListNode); } List select(Predicate f, List& x) { ListNode* a = x.P; ListNode* h = &NilListNode; while (a != &NilListNode) { if ((*f)(a->hd)) { h = newListNode(a->hd); ListNode* trail = h; for(a = a->tl; a != &NilListNode; a = a->tl) { if ((*f)(a->hd)) { ListNode* n = newListNode(a->hd); trail->tl = n; trail = n; } } trail->tl = &NilListNode; break; } else a = a->tl; } return List(h); } List remove(Predicate f, List& x) { ListNode* a = x.P; ListNode* h = &NilListNode; while (a != &NilListNode) { if (!(*f)(a->hd)) { h = newListNode(a->hd); ListNode* trail = h; for(a = a->tl; a != &NilListNode; a = a->tl) { if (!(*f)(a->hd)) { ListNode* n = newListNode(a->hd); trail->tl = n; trail = n; } } trail->tl = &NilListNode; break; } else a = a->tl; } return List(h); } List remove( targ, List& x) { ListNode* a = x.P; ListNode* h = &NilListNode; while (a != &NilListNode) { if (!(a->hd == targ)) { h = newListNode(a->hd); ListNode* trail = h; for(a = a->tl; a != &NilListNode; a = a->tl) { if (!(a->hd == targ)) { ListNode* n = newListNode(a->hd); trail->tl = n; trail = n; } } trail->tl = &NilListNode; break; } else a = a->tl; } return List(h); } List map(Mapper f, List& x) { ListNode* a = x.P; ListNode* h = &NilListNode; if (a != &NilListNode) { h = newListNode((*f)(a->hd)); ListNode* trail = h; for(a = a->tl; a != &NilListNode; a = a->tl) { ListNode* n = newListNode((*f)(a->hd)); trail->tl = n; trail = n; } trail->tl = &NilListNode; } return List(h); } List merge(List& x, List& y, Comparator f) { ListNode* a = x.P; ListNode* b = y.P; if (a == &NilListNode) { if (b == &NilListNode) return List(&NilListNode); else return copy(y); } else if (b == &NilListNode) return copy(x); ListNode* h = new ListNode; h->ref = 1; if ((*f)(a->hd, b->hd) <= 0) { h->hd = a->hd; a = a->tl; } else { h->hd = b->hd; b = b->tl; } ListNode* r = h; for(;;) { if (a == &NilListNode) { while (b != &NilListNode) { ListNode* n = new ListNode; n->ref = 1; n->hd = b->hd; r->tl = n; r = n; b = b->tl; } r->tl = &NilListNode; return List(h); } else if (b == &NilListNode) { while (a != &NilListNode) { ListNode* n = new ListNode; n->ref = 1; n->hd = a->hd; r->tl = n; r = n; a = a->tl; } r->tl = &NilListNode; return List(h); } else if ((*f)(a->hd, b->hd) <= 0) { ListNode* n = new ListNode; n->ref = 1; n->hd = a->hd; r->tl = n; r = n; a = a->tl; } else { ListNode* n = new ListNode; n->ref = 1; n->hd = b->hd; r->tl = n; r = n; b = b->tl; } } } void List::sort(Comparator f) { // strategy: place runs in queue, merge runs until done // This is often very fast if (P == &NilListNode || P->tl == &NilListNode) return; int qlen = 250; // guess a good queue size, realloc if necessary ListNode** queue = (ListNode**)malloc(qlen * sizeof(ListNode*)); ListNode* h = P; ListNode* a = h; ListNode* b = a->tl; int qin = 0; while (b != &NilListNode) { if ((*f)(a->hd, b->hd) > 0) { if (h == a) // minor optimization: ensure runlen >= 2 { h = b; a->tl = b->tl; b->tl = a; b = a->tl; } else { if (qin >= qlen) { qlen *= 2; queue = (ListNode**)realloc(queue, qlen * sizeof(ListNode*)); } queue[qin++] = h; a->tl = &NilListNode; h = a = b; b = b->tl; } } else { a = b; b = b->tl; } } int count = qin; queue[qin] = h; if (++qin >= qlen) qin = 0; int qout = 0; while (count-- > 0) { a = queue[qout]; if (++qout >= qlen) qout = 0; b = queue[qout]; if (++qout >= qlen) qout = 0; if ((*f)(a->hd, b->hd) <= 0) { h = a; a = a->tl; } else { h = b; b = b->tl; } queue[qin] = h; if (++qin >= qlen) qin = 0; for (;;) { if (a == &NilListNode) { h->tl = b; break; } else if (b == &NilListNode) { h->tl = a; break; } else if ((*f)(a->hd, b->hd) <= 0) { h->tl = a; h = a; a = a->tl; } else { h->tl = b; h = b; b = b->tl; } } } P = queue[qout]; free(queue); } int List::list_length() { ListNode* fast = P; if (fast == &NilListNode) return 0; ListNode* slow = fast->tl; if (slow == &NilListNode) return 1; fast = slow->tl; int n = 2; for (;;) { if (fast == &NilListNode) return n; else if (fast->tl == &NilListNode) return n+1; else if (fast == slow) return -1; else { n += 2; fast = fast->tl->tl; slow = slow->tl; } } } void List::error(const char* msg) { (*lib_error_handler)("List", msg); } int List::OK() { int v = P != 0; // have a node // check that all nodes OK, even if circular: ListNode* fast = P; if (fast != &NilListNode) { v &= fast->ref != 0; ListNode* slow = fast->tl; v &= slow->ref != 0; if (v && slow != &NilListNode) { fast = slow->tl; v &= fast->ref != 0; while (v) { if (fast == &NilListNode) break; else if (fast->tl == &NilListNode) break; else if (fast == slow) break; else { v &= fast->ref != 0 && slow->ref != 0; fast = fast->tl->tl; slow = slow->tl; } } } } if (!v) error ("invariant failure"); return v; } 0707070000020177201004440000020000020000011450020460565003200002400000002716g++-include/Map.ccP// 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. */ #include #include "..Map.h" Pix Map::seek( item) { for (Pix i = first(); i != 0 && !(EQ(key(i), item)); next(i)); return i; } int Map::owns(Pix idx) { if (idx == 0) return 0; for (Pix i = first(); i; next(i)) if (i == idx) return 1; return 0; } void Map::clear() { Pix i = first(); while (i != 0) { del(key(i)); i = first(); } } int Map::contains ( item) { return seek(item) != 0; } void Map::error(const char* msg) { (*lib_error_handler)("Set", msg); } 0707070000020177211004440000020000020000011413310460565003600002600000040353g++-include/MPlex.ccP// 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. */ #include ".MPlex.h" // MChunk support MChunk::MChunk(* d, int baseidx, int lowidx, int fenceidx, int topidx) : IChunk(d, baseidx, lowidx, fenceidx, topidx) { unused = fence - low; unsigned msize = (top - base)/_MAP_BITS + 1; map = (unsigned long *) (new long[msize]); bzero((void*)map, msize * sizeof(long)); } void MChunk:: shrink_high () { if (fence <= low) empty_error(); --fence; if (!valid(fence)) --unused; else free(fence); reset_high(); } void MChunk:: shrink_low () { if (fence <= low) empty_error(); if (!valid(low)) --unused; else free(low); ++low; reset_low(); } void MChunk::clear(int lo) { int s = top - base; low = base = fence = lo; top = base + s; unused = 0; bzero((void*)map, ((top - base)/_MAP_BITS + 1) * sizeof(long)); } void MChunk::cleardown(int hi) { int s = top - base; low = top = fence = hi; base = top - s; unused = 0; bzero((void*)map, ((top - base)/_MAP_BITS + 1) * sizeof(long)); } int MChunk::del(int idx) { if (idx < low || idx >= fence) index_error(); int v = valid(idx); if (v) { free(idx); ++unused; } return v; } int MChunk::undel(int idx) { if (idx < low || idx >= fence) index_error(); int v = valid(idx); if (!v) { mark(idx); --unused; } return v; } int MChunk::unused_index() const { if (unused_indices() == 0) index_error(); int slot; if (low == base) // can traverse 32 slots at a time { int blk = 0; while (map[blk] == ~0L) ++blk; slot = blk * _MAP_BITS + base; } else slot = low; while(valid(slot)) ++slot; return slot; } int MChunk::first_index() const { if (empty()) return fence; int slot; if (low == base) { int blk = 0; while (map[blk] == 0) ++blk; slot = blk * _MAP_BITS + base; } else slot = low; while(!valid(slot)) ++slot; return slot; } int MChunk::last_index() const { if (empty()) return low - 1; int slot; if (top == fence) { int blk = (top - base) / _MAP_BITS; while (map[blk] == 0) --blk; slot = blk * _MAP_BITS + base + _MAP_BITS - 1; } else slot = fence - 1; while(!valid(slot)) --slot; return slot; } int MChunk:: OK() const { int v = data != 0; // have some data v &= map != 0; // and a map v &= base <= low; // ok, index-wise v &= low <= fence; v &= fence <= top; v &= nxt->prev() == this; // and links are OK v &= prv->next() == this; int bitcount = 0; // and unused count correct for (int i = low; i < fence; ++i) if (!valid(i)) ++bitcount; v &= unused == bitcount; if (!v) error("invariant failure"); return(v); } * MChunk::succ(* p) const { int i = ((int) p - (int) data) / sizeof() + base + 1; if (p == 0 || i < low) return 0; while (i < fence && !valid(i)) ++i; if (i >= fence) return 0; return pointer_to(i); } * MChunk::pred(* p) const { int i = ((int) p - (int) data) / sizeof() + base - 1; if (p == 0 || i >= fence) return 0; while (i >= low && !valid(i)) --i; if (i < low) return 0; return pointer_to(i); } * MChunk::first_pointer() const { if (empty()) return 0; int slot; if (low == base) { int blk = 0; while (map[blk] == 0) ++blk; slot = blk * _MAP_BITS + base; } else slot = low; while(!valid(slot)) ++slot; return pointer_to(slot); } * MChunk::last_pointer() const { if (empty()) return 0; int slot; if (top == fence) { int blk = (top - base) / _MAP_BITS; while (map[blk] == 0) --blk; slot = blk * _MAP_BITS + base + _MAP_BITS - 1; } else slot = fence - 1; while(!valid(slot)) --slot; return pointer_to(slot); } MPlex:: MPlex() { unused = 0; lo = fnc = 0; csize = DEFAULT_INITIAL_CAPACITY; * data = new [csize]; hd = ch = new MChunk(data, lo, lo, fnc, lo+csize); } MPlex:: MPlex(int chunksize) { if (chunksize == 0) error("invalid constructor specification"); unused = 0; lo = fnc = 0; if (chunksize > 0) { csize = chunksize; * data = new [csize]; hd = ch = new MChunk(data, lo, lo, fnc, csize); } else { csize = -chunksize; * data = new [csize]; hd = ch = new MChunk(data, chunksize, lo, fnc, fnc); } } MPlex:: MPlex(int l, int chunksize) { if (chunksize == 0) error("invalid constructor specification"); unused = 0; lo = fnc = l; if (chunksize > 0) { csize = chunksize; * data = new [csize]; hd = ch = new MChunk(data, lo, lo, fnc, csize+lo); } else { csize = -chunksize; * data = new [csize]; hd = ch = new MChunk(data, chunksize+lo, lo, fnc, fnc); } } void MPlex::make_initial_chunks(int up = 1) { int need = fnc - lo; hd = 0; if (up) { int l = lo; do { int sz; if (need >= csize) sz = csize; else sz = need; * data = new [csize]; MChunk* h = new MChunk(data, l, l, l+sz, l+csize); if (hd != 0) h->link_to_next(hd); else hd = h; l += sz; need -= sz; } while (need > 0); } else { int hi = fnc; do { int sz; if (need >= csize) sz = csize; else sz = need; * data = new [csize]; MChunk* h = new MChunk(data, hi-csize, hi-sz, hi, hi); if (hd != 0) h->link_to_next(hd); hd = h; hi -= sz; need -= sz; } while (need > 0); } ch = (MChunk*) hd; } MPlex:: MPlex(int l, int hi, const initval, int chunksize = 0) { unused = 0; lo = l; fnc = hi + 1; if (chunksize == 0) { csize = fnc - l; make_initial_chunks(1); } else if (chunksize < 0) { csize = -chunksize; make_initial_chunks(0); } else { csize = chunksize; make_initial_chunks(1); } fill(initval); } MPlex::MPlex(const MPlex& a) { lo = a.lo; fnc = a.fnc; csize = a.csize; unused = fnc - lo; hd = 0; const IChunk* p = a.hd; do { * data = new [p->size()]; MChunk* h = new MChunk(data, p->base_index(), p->low_index(), p->fence_index(), p->top_index()); if (hd != 0) h->link_to_next(hd); else hd = h; p = p->next(); } while (p != a.hd); ch = (MChunk*) hd; for (int i = a.low(); i < a.fence(); a.next(i)) { undel_index(i); (*this)[i] = a[i]; } } void MPlex::operator= (const MPlex& a) { if (&a != this) { invalidate(); lo = a.lo; fnc = a.fnc; csize = a.csize; unused = fnc - lo; hd = 0; const IChunk* p = a.hd; do { * data = new [p->size()]; MChunk* h = new MChunk(data, p->base_index(), p->low_index(), p->fence_index(), p->top_index()); if (hd != 0) h->link_to_next(hd); else hd = h; p = p->next(); } while (p != a.hd); ch = (MChunk*) hd; for (int i = a.low(); i < a.fence(); a.next(i)) { undel_index(i); (*this)[i] = a[i]; } } } int MPlex::valid(int idx) const { const MChunk* tail = (MChunk*)tl(); const MChunk* t = ch; while (idx >= t->fence_index()) { if (t == tail) return 0; t = ((MChunk*)(t->next())); } while (idx < t->low_index()) { if (t == hd) return 0; t = ((MChunk*)(t->prev())); } set_cache(t); return t->MChunk::valid_index(idx); } void MPlex::cache(int idx) const { const MChunk* tail = (MChunk*)tl(); const MChunk* t = ch; while (idx >= t->fence_index()) { if (t == tail) index_error(); t = ((MChunk*)(t->next())); } while (idx < t->low_index()) { if (t == hd) index_error(); t = ((MChunk*)(t->prev())); } if (!t->MChunk::valid_index(idx)) index_error(); set_cache(t); } void MPlex::cache(const * p) const { const MChunk* old = ch; const MChunk* t = ch; while (!t->actual_pointer(p)) { t = ((MChunk*)(t->next())); if (t == old) index_error(); } if (!t->MChunk::valid_pointer(p)) index_error(); set_cache(t); } int MPlex::owns(Pix p) const { const MChunk* old = ch; const MChunk* t = ch; while (!t->actual_pointer(p)) { t = ((MChunk*)(t->next())); if (t == old) return 0; } set_cache(t); return t->MChunk::valid_pointer(p); } int MPlex::add_high(const elem) { MChunk* t = ((MChunk*) tl()); if (!t->can_grow_high()) { * data = new [csize]; t = (new MChunk(data, fnc,fnc,fnc,fnc+csize)); t->link_to_prev(tl()); } *((t->MChunk::grow_high())) = elem; set_cache(t); return fnc++; } int MPlex::add_low (const elem) { MChunk* t = ((MChunk*) hd); if (!t->can_grow_low()) { * data = new [csize]; hd = new MChunk(data, lo-csize, lo, lo, lo); hd->link_to_next(t); t = ((MChunk*) hd); } *((t->MChunk::grow_low())) = elem; set_cache(t); return --lo; } void MPlex::adjust_bounds() { MChunk* t = ((MChunk*) tl()); while (t->MChunk::empty() && !one_chunk()) { MChunk* pred = (MChunk*)(t->prev()); del_chunk(t); pred->reset_high(); t = (pred); } int oldfnc = fnc; fnc = t->fence_index(); unused -= oldfnc - fnc - 1; t = ((MChunk*) hd); while (t->MChunk::empty() && !one_chunk()) { hd = (MChunk*)(t->next()); del_chunk(t); t = ((MChunk*) hd); t->reset_low(); } int oldlo = lo; lo = t->low_index(); unused -= lo - oldlo - 1; set_cache(t); } int MPlex::del_high () { if (empty()) empty_error(); MChunk* t = ((MChunk*) tl()); while (t->MChunk::empty() && !one_chunk()) // possible stragglers { MChunk* pred = (MChunk*)(t->prev()); del_chunk(t); pred->reset_high(); t = (pred); } t->MChunk::shrink_high(); while (t->MChunk::empty() && !one_chunk()) { MChunk* pred = (MChunk*)(t->prev()); del_chunk(t); pred->reset_high(); t = (pred); } int oldfnc = fnc; fnc = t->fence_index(); unused -= oldfnc - fnc - 1; set_cache(t); return fnc - 1; } int MPlex::del_low () { if (empty()) empty_error(); MChunk* t = ((MChunk*) hd); while (t->MChunk::empty() && !one_chunk()) { hd = (MChunk*)(t->next()); del_chunk(t); t = ((MChunk*) hd); t->reset_low(); } t->MChunk::shrink_low(); while (t->MChunk::empty() && !one_chunk()) { hd = (MChunk*)(t->next()); del_chunk(t); t = ((MChunk*) hd); t->reset_low(); } int oldlo = lo; lo = t->low_index(); unused -= lo - oldlo - 1; set_cache(t); return lo; } int MPlex::add(const elem) { if (unused == 0) return add_high(elem); for(MChunk* t = ch; t->unused_indices() == 0; t = (MChunk*)(t->prev())) ; int i = t->unused_index(); set_cache(t); undel_index(i); (*this)[i] = elem; return i; } int MPlex::unused_index() const { if (unused == 0) index_error(); for(MChunk* t = ch; t->unused_indices() == 0; t = (MChunk*)(t->prev())) ; set_cache(t); return t->unused_index(); } Pix MPlex::unused_Pix() const { if (unused == 0) return 0; for(MChunk* t = ch; t->unused_indices() == 0; t = (MChunk*)(t->prev())) ; set_cache(t); return t->pointer_to(t->unused_index()); } int MPlex::del_index(int idx) { if (idx < lo || idx >= fnc) index_error(); if (MPlex::valid(idx)) { ++unused; ch->MChunk::del(idx); return 1; } else return 0; } int MPlex::dopred(int idx) const { if (idx >= fnc) idx = fnc; if (idx <= lo) return lo - 1; const MChunk* t = ch; while (idx > t->fence_index()) { t = ((MChunk*)(t->next())); } while (idx <= t->low_index()) { t = ((MChunk*)(t->prev())); } int i = t->MChunk::pred(idx); while (i < t->low_index() && i >= lo) { t = ((MChunk*)(t->prev())); i = t->MChunk::last_index(); } set_cache(t); return i; } int MPlex::dosucc(int idx) const { if (idx < lo) idx = lo; if (idx >= fnc - 1) return fnc; const MChunk* t = ch; while (idx >= t->fence_index()) { t = ((MChunk*)(t->next())); } while (idx < t->low_index()) { t = ((MChunk*)(t->prev())); } int i = t->MChunk::succ(idx); while (i >= t->fence_index() && i < fnc) { t = (MChunk*)(t->next()); i = t->MChunk::first_index(); } set_cache(t); return i; } void MPlex::prev(Pix& i) const { if (i == 0) return; * p = (*) i; const MChunk* old = ch; const MChunk* t = ch; while (!t->actual_pointer(p)) { t = ((MChunk*)(t->prev())); if (t == old) { i = 0; return; } } * q = t->MChunk::pred(p); while (q == 0 && t != hd) { t = ((MChunk*)(t->prev())); q = t->MChunk::last_pointer(); } i = Pix(q); set_cache(t); return; } void MPlex::next(Pix& i) const { if (i == 0) return; * p = (*) i; const MChunk* tail = (MChunk*)(tl()); const MChunk* old = ch; const MChunk* t = ch; while (!t->actual_pointer(p)) { t = ((MChunk*)(t->next())); if (t == old) { i = 0; return; } } * q = t->MChunk::succ(p); while (q == 0 && t != tail) { t = ((MChunk*)(t->next())); q = t->MChunk::first_pointer(); } i = Pix(q); set_cache(t); return; } void MPlex::undel_index(int idx) { if (idx < lo || idx >= fnc) index_error(); const MChunk* t = ch; while (idx >= t->fence_index()) { t = ((MChunk*)(t->next())); } while (idx < t->low_index()) { t = ((MChunk*)(t->prev())); } int was_present = t->MChunk::undel(idx); if (!was_present) { --unused; } set_cache(t); return; } void MPlex::clear() { if (fnc != lo) { MChunk* t = ((MChunk*)tl()); while (t != hd) { MChunk* prv = (MChunk*)(t->prev()); del_chunk(t); t = prv; } t->MChunk::clear(lo); set_cache(t); fnc = lo; unused = 0; } } int MPlex::OK () const { int v = hd != 0; // at least one chunk int found_ch = 0; // to make sure ch is in list; int count = 0; // to count unused slots const MChunk* t = (MChunk*)(hd); int gap = t->low_index() - lo; v &= gap == 0; // hd lo not less than lo. count += gap; for (;;) { if (t == ch) ++found_ch; v &= t->MChunk::OK(); // each chunk is OK count += t->unused_indices(); if (t == tl()) break; else // and has indices less than succ { gap = t->next()->base_index() - t->top_index(); v &= gap == 0; count += gap; if (t != hd) // internal chunks can't grow v &= !t->can_grow_low() && !t->can_grow_high(); t = (const MChunk*)(t->next()); } } gap = fnc - t->fence_index(); v &= gap == 0; count += gap; v &= count == unused; // chunk counts agree with plex v &= found_ch == 1; if (!v) error("invariant failure"); return v; } 0707070000020177221004440000020000020000011543200460565004000002500000025701g++-include/MPlex.hP// 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 _MPlex_h #pragma once #define _MPlex_h 1 #include ".Plex.h" // Number of bits per long, used in MChunk bit map operations #define _MAP_BITS 32 class MChunk : public IChunk { protected: unsigned long* map; // bitmap of slots int unused; // number of unused internal slots void mark(int); // bitmap operations void free(int); int valid(int) const; public: MChunk(* d, // ptr to array of elements int base_idx, // initial indices int low_idx, // & initially clear map int fence_idx, int top_idx); ~MChunk(); // virtuals int first_index() const; int last_index() const; int succ(int idx) const; int pred(int idx) const; * first_pointer() const; * last_pointer() const; * succ(*) const; * pred(*) const; int empty() const; int full() const; int valid_index(int i) const; int valid_pointer(const * p) const; * grow_high (); * grow_low (); void shrink_high (); void shrink_low (); void clear(int); void cleardown(int); int OK() const; // extensions int unused_indices() const; // how many free slot in low..fence? int unused_index() const; // return index of free slot int del(int i); // delete data indexed by i // return true if was present int undel(int idx); // un-delete data indexed by i // return true if already present void reset_low(); // reset low = lowest valid index; void reset_high(); // same for high }; class MPlex: public Plex { MChunk* ch; // cached chunk int unused; // # of free slots between low & fence void make_initial_chunks(int up = 1); void cache(int idx) const; void cache(const * p) const; int dopred(int) const; int dosucc(int) const; void set_cache(const MChunk* t) const; // logically, // not physically const public: MPlex(); // set low = 0; // fence = 0; // csize = default MPlex(int ch_size); // low = 0; // fence = 0; // csize = ch_size MPlex(int lo, // low = lo; int ch_size); // fence=lo // csize = ch_size MPlex(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 MPlex(const MPlex&); void operator= (const MPlex&); // 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 clear(); int OK () const; // extensions int count() const; // # valid elements int available() const; // # deleted elements int unused_index()const; // return index of a deleted elem Pix unused_Pix() const; // return Pix of a deleted elem int del_index(int idx); // logically delete at idx; // return true if was present int del_Pix(Pix p); // delete at p void undel_index(int idx); // undelete at idx; void undel_Pix(Pix p); // undelete at p; void adjust_bounds(); // reset lo, hi to lowest & // highest valid indices int add(const elem); // add anywhere }; inline MChunk:: ~MChunk() { delete map; } inline void MChunk::mark(int idx) { unsigned int i = idx - base; map[i / _MAP_BITS] |= 1 << (i & (_MAP_BITS - 1)); } inline void MChunk::free(int idx) { unsigned int i = idx - base; map[i / _MAP_BITS] &= ~(1 << (i & (_MAP_BITS - 1))); } inline int MChunk::valid(int idx) const { unsigned int i = idx - base; return map[i / _MAP_BITS] & (1 << (i & (_MAP_BITS - 1))); } inline int MChunk:: valid_index(int i) const { return i >= low && i < fence && valid(i); } inline int MChunk:: valid_pointer(const * p) const { int i = ((int)p - (int)data) / sizeof(); return i >= 0 && i < (fence - base) && (map[(unsigned)i / _MAP_BITS] & (1 << (i & (_MAP_BITS - 1)))); } inline int MChunk::empty() const { return fence - low - unused == 0; } inline int MChunk::full() const { return unused + (top - fence) + (low - base) == 0; } inline int MChunk::succ(int idx) const { int i = (idx < low)? low : idx + 1; while (i < fence && !valid(i)) ++i; return i; } inline int MChunk::pred(int idx) const { int i = (idx > fence)? (fence - 1) : idx - 1; while (i >= low && !valid(i)) --i; return i; } inline int MChunk::unused_indices() const { return unused; } inline * MChunk:: grow_high () { if (!can_grow_high()) full_error(); mark(fence); return &(data[fence++ - base]); } inline * MChunk:: grow_low () { if (!can_grow_low()) full_error(); mark(--low); return &(data[low - base]); } inline void MChunk::reset_low() { while (low < fence && !valid(low)) { --unused; ++low; } } inline void MChunk::reset_high() { while (fence > low && !valid(fence - 1)) { --unused; --fence; } } inline int MPlex::full () const { return 0; } inline int MPlex::can_add_high() const { return 1; } inline int MPlex::can_add_low() const { return 1; } inline int MPlex::available() const { return unused; } inline int MPlex::count() const { return fnc - lo - unused; } inline void MPlex::set_cache(const MChunk* t) const { ((MPlex*)(this))->ch = t; } inline & MPlex:: operator [] (int idx) { if (!ch->MChunk::valid_index(idx)) cache(idx); return * (ch->pointer_to(idx)); } inline const & MPlex:: operator [] (int idx) const { if (!ch->MChunk::valid_index(idx)) cache(idx); return * ((const *)(ch->pointer_to(idx))); } inline int MPlex::Pix_to_index(Pix p) const { if (!ch->MChunk::valid_pointer((*)p)) cache((*)p); return ch->index_of((*)p); } inline int MPlex::high() const { return (unused == fnc - lo)? lo - 1 : (((const MChunk*)tl())->MChunk::last_index()); } inline int MPlex::low() const { return (unused == fnc - lo)? fnc : (((const MChunk*)hd)->MChunk::first_index()); } inline & MPlex::low_element () { if (unused == fnc - lo) index_error(); return *((hd->pointer_to(((MChunk*)(hd))->MChunk::first_index()))); } inline const & MPlex::low_element () const { if (unused == fnc - lo) index_error(); return *((const *)((((MChunk*)(hd))-> pointer_to(((MChunk*)(hd))-> MChunk::first_index())))); } inline & MPlex::high_element () { if (unused == fnc - lo) index_error(); return *((*)((((MChunk*)tl())-> pointer_to(((MChunk*)tl())->MChunk::last_index())))); } inline const & MPlex::high_element () const { if (unused == fnc - lo) index_error(); return *((const *)((((MChunk*)tl())->pointer_to(((MChunk*)tl())->MChunk::last_index())))); } inline Pix MPlex::index_to_Pix(int idx) const { if (!ch->MChunk::valid_index(idx)) cache(idx); return Pix(ch->pointer_to(idx)); } inline void MPlex::next(int& idx) const { idx = (ch->MChunk::valid_index(idx+1))? idx+1 : dosucc(idx); } inline void MPlex::prev(int& idx) const { idx = (ch->MChunk::valid_index(idx-1))? idx-1 : dopred(idx); } inline Pix MPlex::first() const { return Pix(((MChunk*)(hd))->MChunk::first_pointer()); } inline Pix MPlex::last() const { return Pix(((MChunk*)(tl()))->MChunk::last_pointer()); } inline void MPlex::undel_Pix(Pix p) { undel_index(Pix_to_index(p)); } inline int MPlex::del_Pix(Pix p) { return del_index(Pix_to_index(p)); } inline & MPlex:: operator () (Pix p) { return *((*)p); } inline const & MPlex:: operator () (Pix p) const { return *((const *)p); } #endif 0707070000020177231004440000020000020000010703150460565004300002400000026451g++-include/Vec.ccP// 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. */ #include #include ".Vec.h" // error handling void default_Vec_error_handler(const char* msg) { cerr << "Fatal Vec error. " << msg << "\n"; exit(1); } one_arg_error_handler_t Vec_error_handler = default_Vec_error_handler; one_arg_error_handler_t set_Vec_error_handler(one_arg_error_handler_t f) { one_arg_error_handler_t old = Vec_error_handler; Vec_error_handler = f; return old; } void Vec::error(const char* msg) { (*Vec_error_handler)(msg); } void Vec::range_error() { (*Vec_error_handler)("Index out of range."); } // can't just realloc since there may be need for constructors/destructors void Vec::resize(int newl) { * news = new [newl]; * p = news; int minl = len * top = &(s[minl]); * t = s; while (t < top) *p++ = *t++; delete [len] s; s = news; len = newl; } Vec concat(Vec & a, Vec & b) { int newl = a.len + b.len; * news = new [newl]; * p = news; * top = &(a.s[a.len]); * t = a.s; while (t < top) *p++ = *t++; top = &(b.s[b.len]); t = b.s; while (t < top) *p++ = *t++; return Vec(newl, news); } Vec combine(Combiner f, Vec& a, Vec& b) { int newl = a.len * news = new [newl]; * p = news; * top = &(a.s[newl]); * t = a.s; * u = b.s; while (t < top) *p++ = (*f)(*t++, *u++); return Vec(newl, news); } Vec::reduce(Combiner f, base) { r = base; * top = &(s[len]); * t = s; while (t < top) r = (*f)(r, *t++); return r; } Vec reverse(Vec& a) { * news = new [a.len]; if (a.len != 0) { * lo = news; * hi = &(news[a.len - 1]); while (lo < hi) { tmp = *lo; *lo++ = *hi; *hi-- = tmp; } } return Vec(a.len, news); } void Vec::reverse() { if (len != 0) { * lo = s; * hi = &(s[len - 1]); while (lo < hi) { tmp = *lo; *lo++ = *hi; *hi-- = tmp; } } } int Vec::index( targ) { for (int i = 0; i < len; ++i) if (targ == s[i]) return i; return -1; } Vec map(Mapper f, Vec& a) { * news = new [a.len]; * p = news; * top = &(a.s[a.len]); * t = a.s; while(t < top) *p++ = (*f)(*t++); return Vec(a.len, news); } int operator == (Vec& a, Vec& b) { if (a.len != b.len) return 0; * top = &(a.s[a.len]); * t = a.s; * u = b.s; while (t < top) if (*t++ != *u++) return 0; return 1; } void Vec::fill( val, int from = 0, int n = -1) { int to; if (n < 0) to = len - 1; else to = from + n - 1; if ((unsigned)from > to) range_error(); * t = &(s[from]); * top = &(s[to]); while (t <= top) *t++ = val; } Vec Vec::at(int from = 0, int n = -1) { int to; if (n < 0) { n = len - from; to = len - 1; } else to = from + n - 1; if ((unsigned)from > to) range_error(); * news = new [n]; * p = news; * t = &(s[from]); * top = &(s[to]); while (t <= top) *p++ = *t++; return Vec(n, news); } Vec merge(Vec & a, Vec & b, Comparator f) { int newl = a.len + b.len; * news = new [newl]; * p = news; * topa = &(a.s[a.len]); * as = a.s; * topb = &(b.s[b.len]); * bs = b.s; for (;;) { if (as >= topa) { while (bs < topb) *p++ = *bs++; break; } else if (bs >= topb) { while (as < topa) *p++ = *as++; break; } else if ((*f)(*as, *bs) <= 0) *p++ = *as++; else *p++ = *bs++; } return Vec(newl, news); } static int gsort(*, int, Comparator); void Vec::sort (Comparator compar) { gsort(s, len, compar); } // An adaptation og Schmidt's new quicksort static inline void SWAP(* A, * B) { tmp = *A; *A = *B; *B = tmp; } /* This should be replaced by a standard ANSI macro. */ #define BYTES_PER_WORD 8 /* The next 4 #defines implement a very fast in-line stack abstraction. */ #define STACK_SIZE (BYTES_PER_WORD * sizeof (long)) #define PUSH(LOW,HIGH) do {top->lo = LOW;top++->hi = HIGH;} while (0) #define POP(LOW,HIGH) do {LOW = (--top)->lo;HIGH = top->hi;} while (0) #define STACK_NOT_EMPTY (stack < top) /* Discontinue quicksort algorithm when partition gets below this size. This particular magic number was chosen to work best on a Sun 4/260. */ #define MAX_THRESH 4 /* Order size using quicksort. This implementation incorporates four optimizations discussed in Sedgewick: 1. Non-recursive, using an explicit stack of pointer that store the next array partition to sort. To save time, this maximum amount of space required to store an array of MAX_INT is allocated on the stack. Assuming a 32-bit integer, this needs only 32 * sizeof (stack_node) == 136 bits. Pretty cheap, actually. 2. Chose the pivot element using a median-of-three decision tree. This reduces the probability of selecting a bad pivot value and eliminates certain extraneous comparisons. 3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving insertion sort to order the MAX_THRESH items within each partition. This is a big win, since insertion sort is faster for small, mostly sorted array segements. 4. The larger of the two sub-partitions is always pushed onto the stack first, with the algorithm then concentrating on the smaller partition. This *guarantees* no more than log (n) stack size is needed! */ static int gsort ( *base_ptr, int total_elems, Comparator cmp) { /* Stack node declarations used to store unfulfilled partition obligations. */ struct stack_node { *lo; *hi; }; pivot_buffer; int max_thresh = MAX_THRESH; if (total_elems > MAX_THRESH) { *lo = base_ptr; *hi = lo + (total_elems - 1); *left_ptr; *right_ptr; stack_node stack[STACK_SIZE]; /* Largest size needed for 32-bit int!!! */ stack_node *top = stack + 1; while (STACK_NOT_EMPTY) { { *pivot = &pivot_buffer; { /* Select median value from among LO, MID, and HI. Rearrange LO and HI so the three values are sorted. This lowers the probability of picking a pathological pivot value and skips a comparison for both the LEFT_PTR and RIGHT_PTR. */ *mid = lo + ((hi - lo) >> 1); if ((*cmp) (*mid, *lo) < 0) SWAP (mid, lo); if ((*cmp) (*hi, *mid) < 0) { SWAP (mid, hi); if ((*cmp) (*mid, *lo) < 0) SWAP (mid, lo); } *pivot = *mid; pivot = &pivot_buffer; } left_ptr = lo + 1; right_ptr = hi - 1; /* Here's the famous ``collapse the walls'' section of quicksort. Gotta like those tight inner loops! They are the main reason that this algorithm runs much faster than others. */ do { while ((*cmp) (*left_ptr, *pivot) < 0) left_ptr += 1; while ((*cmp) (*pivot, *right_ptr) < 0) right_ptr -= 1; if (left_ptr < right_ptr) { SWAP (left_ptr, right_ptr); left_ptr += 1; right_ptr -= 1; } else if (left_ptr == right_ptr) { left_ptr += 1; right_ptr -= 1; break; } } while (left_ptr <= right_ptr); } /* Set up pointers for next iteration. First determine whether left and right partitions are below the threshold size. If so, ignore one or both. Otherwise, push the larger partition's bounds on the stack and continue sorting the smaller one. */ if ((right_ptr - lo) <= max_thresh) { if ((hi - left_ptr) <= max_thresh) /* Ignore both small partitions. */ POP (lo, hi); else /* Ignore small left partition. */ lo = left_ptr; } else if ((hi - left_ptr) <= max_thresh) /* Ignore small right partition. */ hi = right_ptr; else if ((right_ptr - lo) > (hi - left_ptr)) /* Push larger left partition indices. */ { PUSH (lo, right_ptr); lo = left_ptr; } else /* Push larger right partition indices. */ { PUSH (left_ptr, hi); hi = right_ptr; } } } /* Once the BASE_PTR array is partially sorted by quicksort the rest is completely sorted using insertion sort, since this is efficient for partitions below MAX_THRESH size. BASE_PTR points to the beginning of the array to sort, and END_PTR points at the very last element in the array (*not* one beyond it!). */ { *end_ptr = base_ptr + 1 * (total_elems - 1); *run_ptr; *tmp_ptr = base_ptr; *thresh = end_ptr *trav; for (trav = run_ptr + 1; --trav >= run_ptr;) { c = *trav; *hi, *lo; for (hi = lo = trav; (lo -= 1) >= tmp_ptr; hi = lo) *hi = *lo; *hi = c; } } } } return 1; } 0707070000020177241004440000020000020000011300230460565004500002300000004566g++-include/Map.hP// 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 #pragma once #define _Map_h 1 #include #include ".defs.h" class Map { protected: int count; def; public: Map( dflt); 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 }; 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 0707070000020177251004440000020000020000011355670460565004700002700000006736g++-include/OSLBag.ccP// 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. */ #include ".OSLBag.h" Pix OSLBag::seek( item, Pix i = 0) { if (i == 0) i = p.first(); else next(i); for (; i != 0; p.next(i)) { int cmp = CMP(item, p(i)); if (cmp == 0) return i; else if (cmp < 0) return 0; } return 0; } int OSLBag::nof( item) { int n = 0; for (Pix i = p.first(); i != 0; p.next(i)) { int cmp = CMP(item, p(i)); if (cmp == 0) ++n; else if (cmp < 0) break; } return n; } Pix OSLBag::add( item) { Pix i = p.first(); if (i == 0) { ++count; return p.prepend(item); } int cmp = CMP(item, p(i)); if (cmp <= 0) { ++count; return p.prepend(item); } else { Pix trail = i; p.next(i); for (;;) { if (i == 0) { ++count; return p.append(item); } cmp = CMP(item, p(i)); if (cmp <= 0) { ++count; return p.ins_after(trail, item); } else { trail = i; p.next(i); } } } } void OSLBag::del( item) { Pix i = p.first(); if (i == 0) return; int cmp = CMP(item, p(i)); if (cmp < 0) return; else if (cmp == 0) { --count; p.del_front(); } else { Pix trail = i; p.next(i); while (i != 0) { cmp = CMP(item, p(i)); if (cmp < 0) return; else if (cmp == 0) { --count; p.del_after(trail); return; } else { trail = i; p.next(i); } } } } void OSLBag::remove( item) { Pix i = p.first(); if (i == 0) return; int cmp = CMP(item, p(i)); if (cmp < 0) return; else if (cmp == 0) { do { --count; p.del_front(); i = p.first(); } while (i != 0 && EQ(item, p(i))); } else { Pix trail = i; p.next(i); while (i != 0) { cmp = CMP(item, p(i)); if (cmp < 0) return; else if (cmp == 0) { do { --count; p.del_after(trail); i = trail; next(i); } while (i != 0 && EQ(item, p(i))); return; } else { trail = i; p.next(i); } } } } int OSLBag::OK() { int v = p.OK(); v &= count == p.length(); Pix trail = p.first(); if (trail == 0) v &= count == 0; else { Pix i = trail; next(i); while (i != 0) { v &= CMP(p(trail), p(i)) <= 0; trail = i; next(i); } } if (!v) error("invariant failure"); return v; } 0707070000020177261004440000020000020000010705450460565005100002600000004065g++-include/OSLBag.hP// 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 #pragma once #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(); }; 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 0707070000020177301004440000020000020000011245670460565005300002700000012740g++-include/OSLSet.ccP// 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. */ #include ".OSLSet.h" Pix OSLSet::seek( item) { for (Pix i = p.first(); i != 0; p.next(i)) { int cmp = CMP(item, p(i)); if (cmp == 0) return i; else if (cmp < 0) return 0; } return 0; } Pix OSLSet::add( item) { Pix i = p.first(); if (i == 0) { ++count; return p.prepend(item); } int cmp = CMP(item, p(i)); if (cmp == 0) return i; else if (cmp < 0) { ++count; return p.prepend(item); } else { Pix trail = i; p.next(i); for (;;) { if (i == 0) { ++count; return p.append(item); } cmp = CMP(item, p(i)); if (cmp == 0) return i; else if (cmp < 0) { ++count; return p.ins_after(trail, item); } else { trail = i; p.next(i); } } } } void OSLSet::del( item) { Pix i = p.first(); if (i == 0) return; int cmp = CMP(item, p(i)); if (cmp < 0) return; else if (cmp == 0) { --count; p.del_front(); } else { Pix trail = i; p.next(i); while (i != 0) { cmp = CMP(item, p(i)); if (cmp < 0) return; else if (cmp == 0) { --count; p.del_after(trail); return; } else { trail = i; p.next(i); } } } } int OSLSet::operator <= (OSLSet& b) { if (count > b.count) return 0; Pix i = first(); Pix j = b.first(); for (;;) { if (i == 0) return 1; else if (j == 0) return 0; int cmp = CMP(p(i), b.p(j)); if (cmp == 0) { next(i); b.next(j); } else if (cmp < 0) return 0; else b.next(j); } } int OSLSet::operator == (OSLSet& b) { if (count != b.count) return 0; if (count == 0) return 1; Pix i = p.first(); Pix j = b.p.first(); while (i != 0) { if (!EQ(p(i),b.p(j))) return 0; next(i); b.next(j); } return 1; } void OSLSet::operator |= (OSLSet& b) { if (&b == this || b.count == 0) return; else { Pix j = b.p.first(); Pix i = p.first(); Pix trail = 0; for (;;) { if (j == 0) return; else if (i == 0) { for (; j != 0; b.next(j)) { ++count; p.append(b.p(j)); } return; } int cmp = CMP(p(i), b.p(j)); if (cmp <= 0) { if (cmp == 0) b.next(j); trail = i; next(i); } else { ++count; if (trail == 0) trail = p.prepend(b.p(j)); else trail = p.ins_after(trail, b.p(j)); b.next(j); } } } } void OSLSet::operator -= (OSLSet& b) { if (&b == this) clear(); else if (count != 0 && b.count != 0) { Pix i = p.first(); Pix j = b.p.first(); Pix trail = 0; for (;;) { if (j == 0 || i == 0) return; int cmp = CMP(p(i), b.p(j)); if (cmp == 0) { --count; b.next(j); if (trail == 0) { p.del_front(); i = p.first(); } else { next(i); p.del_after(trail); } } else if (cmp < 0) { trail = i; next(i); } else b.next(j); } } } void OSLSet::operator &= (OSLSet& b) { if (b.count == 0) clear(); else if (&b != this && count != 0) { Pix i = p.first(); Pix j = b.p.first(); Pix trail = 0; for (;;) { if (i == 0) return; else if (j == 0) { if (trail == 0) { p.clear(); count = 0; } else { while (i != 0) { --count; next(i); p.del_after(trail); } } return; } int cmp = CMP(p(i), b.p(j)); if (cmp == 0) { trail = i; next(i); b.next(j); } else if (cmp < 0) { --count; if (trail == 0) { p.del_front(); i = p.first(); } else { next(i); p.del_after(trail); } } else b.next(j); } } } int OSLSet::OK() { int v = p.OK(); v &= count == p.length(); Pix trail = p.first(); if (trail == 0) v &= count == 0; else { Pix i = trail; next(i); while (i != 0) { v &= CMP(p(trail), p(i)) < 0; trail = i; next(i); } } if (!v) error("invariant failure"); return v; } 0707070000020177311004440000020000020000010215350460565005500002600000004475g++-include/OSLSet.hP// 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 #pragma once #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(); }; 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 0707070000020177321004440000020000020000011373140460565005700002700000011226g++-include/OXPBag.ccP// 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. */ #include ".OXPBag.h" Pix OXPBag::seek( item, Pix i = 0) { if (i == 0) { int l = p.low(); int h = p.high(); while (l <= h) { int mid = (l + h) / 2; int cmp = CMP(item, p[mid]); if (cmp == 0) { while (mid > p.low() && EQ(item, p[mid - 1])) --mid; return p.index_to_Pix(mid); } else if (cmp < 0) h = mid - 1; else l = mid + 1; } return 0; } int cmp = CMP(item, p(i)); if (cmp == 0) { next(i); return (EQ(item, p(i)))? i : 0; } else if (cmp < 0) { int ind = p.Pix_to_index(i); int l = ind; int h = p.high(); while (l <= h) { int mid = (l + h) / 2; cmp = CMP(item, p[mid]); if (cmp == 0) { while (mid > ind && EQ(item, p[mid - 1])) --mid; return p.index_to_Pix(mid); } else if (cmp < 0) h = mid - 1; else l = mid + 1; } return 0; } else return 0; } int OXPBag::nof( item) { int l = p.low(); int h = p.high(); while (l <= h) { int mid = (l + h) / 2; int cmp = CMP(item, p[mid]); if (cmp == 0) { l = h = mid; while (l > p.low() && EQ(item, p[l - 1])) --l; while (h < p.high() && EQ(item, p[h + 1])) ++h; return h - l + 1; } else if (cmp < 0) h = mid - 1; else l = mid + 1; } return 0; } Pix OXPBag::add( item) { if (count == 0) { ++count; return p.index_to_Pix(p.add_high(item)); } int l = p.low(); int h = p.high(); while (l <= h) { int mid = (l + h) / 2; int cmp = CMP(item, p[mid]); if (cmp == 0) { l = mid; break; } else if (cmp < 0) h = mid - 1; else l = mid + 1; } // add on whichever side is shortest ++count; if (l == p.fence()) return p.index_to_Pix(p.add_high(item)); else if (l == p.low()) return p.index_to_Pix(p.add_low(item)); else { if (p.high() - l < l - p.low()) { h = p.add_high(p.high_element()); for (int i = h - 1; i > l; --i) p[i] = p[i-1]; } else { --l; h = p.add_low(p.low_element()); for (int i = h + 1; i < l; ++i) p[i] = p[i+1]; } p[l] = item; return p.index_to_Pix(l); } } void OXPBag::del( item) { int l = p.low(); int h = p.high(); while (l <= h) { int mid = (l + h) / 2; int cmp = CMP(item, p[mid]); if (cmp == 0) { --count; if (p.high() - mid < mid - p.low()) { for (int i = mid; i < p.high(); ++i) p[i] = p[i+1]; p.del_high(); } else { for (int i = mid; i > p.low(); --i) p[i] = p[i-1]; p.del_low(); } return; } else if (cmp < 0) h = mid - 1; else l = mid + 1; } } void OXPBag::remove( item) { int l = p.low(); int h = p.high(); while (l <= h) { int mid = (l + h) / 2; int cmp = CMP(item, p[mid]); if (cmp == 0) { l = h = mid; while (l > p.low() && EQ(item, p[l - 1])) --l; while (h < p.high() && EQ(item, p[h + 1])) ++h; int n = h - l + 1; count -= n; if (p.high() - h < l - p.low()) { h = p.high() - n; for (int i = l; i <= h; ++i) p[i] = p[i+n]; while (n-- > 0) p.del_high(); } else { l = p.low() + n; for (int i = h; i >= l; --i) p[i] = p[i-n]; while (n-- > 0) p.del_low(); } return; } else if (cmp < 0) h = mid - 1; else l = mid + 1; } } int OXPBag::OK() { int v = p.OK(); v &= count == p.length(); for (int i = p.low(); i < p.high(); ++i) v &= CMP(p[i], p[i+1]) <= 0; if (!v) error("invariant failure"); return v; } 0707070000020177331004440000020000020000010461560460565006100002600000002352g++-include/OXPBag.hP#ifndef _OXPBag_h #pragma once #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(); }; inline OXPBag::OXPBag(int chunksize = DEFAULT_INITIAL_CAPACITY) : 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 0707070000020177341004440000020000020000011256510460565006300002700000013051g++-include/OXPSet.ccP// 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. */ #include ".OXPSet.h" Pix OXPSet::seek( item) { int l = p.low(); int h = p.high(); while (l <= h) { int mid = (l + h) / 2; int cmp = CMP(item, p[mid]); if (cmp == 0) return p.index_to_Pix(mid); else if (cmp < 0) h = mid - 1; else l = mid + 1; } return 0; } Pix OXPSet::add( item) { if (count == 0) { ++count; return p.index_to_Pix(p.add_high(item)); } int l = p.low(); int h = p.high(); while (l <= h) { int mid = (l + h) / 2; int cmp = CMP(item, p[mid]); if (cmp == 0) return p.index_to_Pix(mid); else if (cmp < 0) h = mid - 1; else l = mid + 1; } // add on whichever side is shortest ++count; if (l == p.fence()) return p.index_to_Pix(p.add_high(item)); else if (l == p.low()) return p.index_to_Pix(p.add_low(item)); else { if (p.fence() - l < l - p.low()) { h = p.add_high(p.high_element()); for (int i = h - 1; i > l; --i) p[i] = p[i-1]; } else { --l; h = p.add_low(p.low_element()); for (int i = h + 1; i < l; ++i) p[i] = p[i+1]; } p[l] = item; return p.index_to_Pix(l); } } void OXPSet::del( item) { int l = p.low(); int h = p.high(); while (l <= h) { int mid = (l + h) / 2; int cmp = CMP(item, p[mid]); if (cmp == 0) { --count; if (p.high() - mid < mid - p.low()) { for (int i = mid; i < p.high(); ++i) p[i] = p[i+1]; p.del_high(); } else { for (int i = mid; i > p.low(); --i) p[i] = p[i-1]; p.del_low(); } return; } else if (cmp < 0) h = mid - 1; else l = mid + 1; } } int OXPSet::operator <= (OXPSet& b) { if (count > b.count) return 0; int i = p.low(); int j = b.p.low(); for (;;) { if (i >= p.fence()) return 1; else if (j >= b.p.fence()) return 0; int cmp = CMP(p[i], b.p[j]); if (cmp == 0) { ++i; ++j; } else if (cmp < 0) return 0; else ++j; } } int OXPSet::operator == (OXPSet& b) { int n = count; if (n != b.count) return 0; if (n == 0) return 1; int i = p.low(); int j = b.p.low(); while (n-- > 0) if (!EQ(p[i++], b.p[j++])) return 0; return 1; } void OXPSet::operator |= (OXPSet& b) { if (&b == this || b.count == 0) return; else if (b.count <= 2) // small b -- just add for (Pix i = b.first(); i; b.next(i)) add(b(i)); else { // strategy: merge into top of p, simultaneously killing old bottom int oldfence = p.fence(); int i = p.low(); int j = b.p.low(); for (;;) { if (i == oldfence) { while (j < b.p.fence()) p.add_high(b.p[j++]); break; } else if (j == b.p.fence()) { while (i++ < oldfence) { p.add_high(p.low_element()); p.del_low(); } break; } int cmp = CMP(p[i], b.p[j]); if (cmp <= 0) { ++i; if (cmp == 0) ++j; p.add_high(p.low_element()); p.del_low(); } else p.add_high(b.p[j++]); } count = p.length(); } } void OXPSet::operator -= (OXPSet& b) { if (&b == this) clear(); else if (count != 0 && b.count != 0) { int i = p.low(); int k = i; int j = b.p.low(); int oldfence = p.fence(); for (;;) { if (i >= oldfence) break; else if (j >= b.p.fence()) { if (k != i) while (i < oldfence) p[k++] = p[i++]; else k = oldfence; break; } int cmp = CMP(p[i], b.p[j]); if (cmp == 0) { ++i; ++j; } else if (cmp < 0) { if (k != i) p[k] = p[i]; ++i; ++k; } else j++; } while (k++ < oldfence) { --count; p.del_high(); } } } void OXPSet::operator &= (OXPSet& b) { if (b.count == 0) clear(); else if (&b != this && count != 0) { int i = p.low(); int k = i; int j = b.p.low(); int oldfence = p.fence(); for (;;) { if (i >= oldfence || j >= b.p.fence()) break; int cmp = CMP(p[i], b.p[j]); if (cmp == 0) { if (k != i) p[k] = p[i]; ++i; ++k; ++j; } else if (cmp < 0) ++i; else ++j; } while (k++ < oldfence) { --count; p.del_high(); } } } int OXPSet::OK() { int v = p.OK(); v &= count == p.length(); for (int i = p.low(); i < p.high(); ++i) v &= CMP(p[i], p[i+1]) < 0; if (!v) error("invariant failure"); return v; } 0707070000020177351004440000020000020000010111360460565006500002600000004634g++-include/OXPSet.hP// 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 #pragma once #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(); }; inline OXPSet::OXPSet(int chunksize = DEFAULT_INITIAL_CAPACITY) : 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 0707070000020177361004440000020000020000010777340460565007000002500000016447g++-include/PHPQ.ccP// 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. */ #include #include ".PHPQ.h" // // This defines a Pairing Heap structure // // See ``The Pairing Heap: A New Form of Self-Adjusting Heap'' // Fredman, Segdewick et al, // Algorithmica (1986) 1:111-129 // // In particular, this implements the pairing heap using the circular // list. // // PHPQ::PHPQ(int sz = DEFAULT_INITIAL_CAPACITY) { storage = 0; root = 0; count = 0; size = 0; prealloc(sz); } PHPQ::PHPQ(PHPQ& a) { storage = 0; root = 0; count = 0; size = 0; prealloc(a.size); for (Pix i = a.first(); i != 0; a.next(i)) enq(a(i)); } void PHPQ::prealloc(int newsize) { ++newsize; // leave a spot for freelist if (size != 0) { int news = size; while (news <= newsize) news = (news * 3) / 2; newsize = news; } // see if indices are OK PHPQNode test; test.sibling = 0; test.sibling = ~test.sibling; if ((unsigned long)newsize > (unsigned long)(test.sibling)) error("storage size exceeds index range"); if (storage == 0) { storage = new PHPQNode[size = newsize]; for (int i = 0; i < size; ++i) { storage[i].sibling = i + 1; storage[i].valid = 0; } storage[size-1].sibling = 0; } else { PHPQNode* newstor = new PHPQNode[newsize]; for (int i = 1; i < size; ++i) newstor[i] = storage[i]; delete [size] storage; storage = newstor; for (i = size; i < newsize; ++i) { storage[i].sibling = i + 1; storage[i].valid = 0; } storage[newsize-1].sibling = 0; storage[0].sibling = size; size = newsize; } } void PHPQ::clear() { for (int i = 0; i < size; ++i) { storage[i].sibling = i + 1; storage[i].valid = 0; } storage[size-1].sibling = 0; root = 0; count = 0; } Pix PHPQ::enq( item) { ++count; if (storage[0].sibling == 0) prealloc(count); int cell = storage[0].sibling; storage[0].sibling = storage[cell].sibling; storage[cell].sibling = 0; storage[cell].children = 0; storage[cell].item = item; storage[cell].valid = 1; if (root == 0) { root = cell; return Pix(root); } else { int parent; int child; if (LE(storage[root].item, storage[cell].item)) { parent = root; child = cell; } else { parent = cell; child = root; } int popsKid = storage[parent].children; if (popsKid == 0) { storage[parent].children = child; storage[child].sibling = child; } else { int temp = storage[popsKid].sibling; storage[popsKid].sibling = child; storage[child].sibling = temp; storage[parent].children = child; } root = parent; return Pix(cell); } } // // Item removal is the most complicated routine. // // We remove the root (should there be one) and then select a new // root. The siblings of the root are in a circular list. We continue // to pair elements in this list until there is a single element. // This element will be the new root. void PHPQ::del_front() { int valid = 0; do { if (root == 0) return; if (valid = storage[root].valid) --count; storage[root].valid = 0; int child = storage[root].children; storage[root].sibling = storage[0].sibling; storage[0].sibling = root; if (child == 0) { root = 0; return; } else { while(storage[child].sibling != child) { // We have at least two kids, but we may only have // two kids. So, oneChild != child, but it is possible // that twoChild == child. int oneChild = storage[child].sibling; int twoChild = storage[oneChild].sibling; // Remove the two from the sibling list storage[child].sibling = storage[twoChild].sibling; storage[oneChild].sibling = 0; storage[twoChild].sibling = 0; int bestChild; int worstChild; if (LE(storage[oneChild].item, storage[twoChild].item)) { bestChild = oneChild; worstChild = twoChild; } else { bestChild = twoChild; worstChild = oneChild; } int popsKid = storage[bestChild].children; if (popsKid == 0) { storage[bestChild].children = worstChild; storage[worstChild].sibling = worstChild; } else { int temp = storage[popsKid].sibling; storage[popsKid].sibling = worstChild; storage[worstChild].sibling = temp; storage[bestChild].children = worstChild; } if (twoChild == child) { // We have reduced the two to one, so we'll be exiting. child = bestChild; storage[child].sibling = child; } else { // We've removed two siblings, now we need to insert // the better of the two storage[bestChild].sibling = storage[child].sibling; storage[child].sibling = bestChild; child = storage[bestChild].sibling; } } root = child; } } while ( !valid ); } void PHPQ::del(Pix p) { if (p == 0) error("null Pix"); int i = int(p); if (storage[i].valid) { if (i == root) del_front(); else { storage[i].valid = 0; --count; } } } Pix PHPQ::seek( key) { for (int i = 1; i < size; ++i) if (storage[i].valid && EQ(storage[i].item, key)) return Pix(i); return 0; } Pix PHPQ::first() { for (int i = 1; i < size; ++i) if (storage[i].valid) return Pix(i); return 0; } void PHPQ::next(Pix& p) { if (p == 0) return; for (int i = int(p)+1; i < size; ++i) if (storage[i].valid) { p = Pix(i); return; } p = 0; } int PHPQ::OK() { int v = storage != 0; int n = check_sibling_list(root, 0); v &= n == count; int ct = MAXLONG; n = 0; int f = storage[0].sibling; while (f != 0 && ct-- > 0) { f = storage[f].sibling; ++n; } v &= ct > 0; v &= n <= size - count; if (!v) error("invariant failure"); return v; } int PHPQ::check_sibling_list(int t, int cnt) { if (t != 0) { int s = t; long ct = MAXLONG; // Lots of chances to find self! do { if (storage[s].valid) cnt++; cnt += check_sibling_list(storage[s].children, cnt); s = storage[s].sibling; } while (ct-- > 0 && s != t && s != 0); if (ct <= 0) return -1; } return cnt; } 0707070000020177371004440000020000020000010625660460565007200002400000004713g++-include/PHPQ.hP// 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 #pragma once #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 }; 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 0707070000020177401004440000020000020000011654320460565007400002300000002721g++-include/PQ.ccP// 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. */ #include #include ".PQ.h" PQ::deq() { x = front(); del_front(); return x; } Pix PQ::seek( item) { for (Pix i = first(); i != 0 && !(EQ((*this)(i), item)); next(i)); return i; } int PQ::owns(Pix idx) { if (idx == 0) return 0; for (Pix i = first(); i; next(i)) if (i == idx) return 1; return 0; } void PQ::clear() { while (count != 0) del_front(); } int PQ::contains ( item) { return seek(item) != 0; } void PQ::error(const char* msg) { (*lib_error_handler)("PQ", msg); } 0707070000020177411004440000020000020000010230040460565007600002200000004341g++-include/PQ.hP// 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 _PQ_h #pragma once #define _PQ_h 1 #include #include ".defs.h" class PQ { protected: int count; public: int length(); // current number of items int empty(); virtual Pix enq( item) = 0; // add item; return Pix virtual deq(); // return & remove min virtual & front() = 0; // access min item virtual void del_front() = 0; // delete min item virtual int contains( item); // is item in PQ? 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 void del(Pix i) = 0; // delete item at i virtual int owns(Pix i); // is i a valid Pix ? virtual Pix seek( item); // Pix of item void error(const char* msg); virtual int OK() = 0; // rep invariant }; inline int PQ::length() { return count; } inline int PQ::empty() { return count == 0; } #endif 0707070000020177421004440000020000020000010371610460565010000002500000010176g++-include/Plex.ccP// 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. */ #include #include ".Plex.h" // IChunk support volatile void IChunk::error(const char* msg) const { (*lib_error_handler)("IChunk", msg); } volatile void IChunk::index_error() const { error("attempt to use invalid index"); } volatile void IChunk::empty_error() const { error("invalid use of empty chunk"); } volatile void IChunk::full_error() const { error("attempt to extend chunk beyond bounds"); } IChunk::IChunk(* d, int baseidx, int lowidx, int fenceidx, int topidx) { if (d == 0 || baseidx > lowidx || lowidx > fenceidx || fenceidx > topidx) error("inconsistent specification"); data = d; base = baseidx; low = lowidx; fence = fenceidx; top = topidx; nxt = prv = this; } void IChunk:: re_index(int lo) { int delta = lo - low; base += delta; low += delta; fence += delta; top += delta; } void IChunk::clear(int lo) { int s = top - base; low = base = fence = lo; top = base + s; } void IChunk::cleardown(int hi) { int s = top - base; low = top = fence = hi; base = top - s; } int IChunk:: OK() const { int v = data != 0; // have some data v &= base <= low; // ok, index-wise v &= low <= fence; v &= fence <= top; v &= nxt->prv == this; // and links are OK v &= prv->nxt == this; if (!v) error("invariant failure"); return(v); } // error handling volatile void Plex::error(const char* msg) const { (*lib_error_handler)("Plex", msg); } volatile void Plex::index_error() const { error("attempt to access invalid index"); } volatile void Plex::empty_error() const { error("attempted operation on empty plex"); } volatile void Plex::full_error() const { error("attempt to increase size of plex past limit"); } // generic plex ops void Plex::append (const Plex& a) { for (int i = a.low(); i < a.fence(); a.next(i)) add_high(a[i]); } void Plex::prepend (const Plex& a) { for (int i = a.high(); i > a.ecnef(); a.prev(i)) add_low(a[i]); } void Plex::reverse() { tmp; int l = low(); int h = high(); while (l < h) { tmp = (*this)[l]; (*this)[l] = (*this)[h]; (*this)[h] = tmp; next(l); prev(h); } } void Plex::fill(const x) { for (int i = lo; i < fnc; ++i) (*this)[i] = x; } void Plex::fill(const x, int lo, int hi) { for (int i = lo; i <= hi; ++i) (*this)[i] = x; } void Plex::del_chunk(IChunk* x) { if (x != 0) { x->unlink(); int sz = x->size(); * data = (*)(x->invalidate()); delete [sz] data; delete x; } } void Plex::invalidate() { IChunk* t = hd; if (t != 0) { IChunk* tail = tl(); while (t != tail) { IChunk* nxt = t->next(); del_chunk(t); t = nxt; } del_chunk(t); hd = 0; } } int Plex::reset_low(int l) { int old = lo; int diff = l - lo; if (diff != 0) { lo += diff; fnc += diff; IChunk* t = hd; do { t->re_index(t->low_index() + diff); t = t->next(); } while (t != hd); } return old; } 0707070000020177431004440000020000020000010612000460565010300002400000031623g++-include/Plex.hP// 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 #pragma once #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; }; // 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() {} 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 Plex:: ~Plex() { invalidate(); } 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 0707070000020177441004440000020000020000010405120460565010500002300000000134g++-include/bool.h #ifndef _bool_h #pragma once #define _bool_h 1 enum bool { FALSE = 0, TRUE = 1 }; #endif 0707070000020177451004440000020000020000011631610460565010700002500000003251g++-include/Queue.hP// 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 #pragma once #define _Queue_h #include #include ".defs.h" class Queue { public: Queue(); ~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; }; inline Queue::Queue() {} inline Queue::~Queue() {} // error handling inline void Queue::error(const char* msg) { (*lib_error_handler)("Queue", msg); } #endif 0707070000020177461004440000020000020000011641420460565011100002600000024242g++-include/RPlex.ccP// 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. */ #include ".RPlex.h" typedef IChunk* _IChunk_ptr; RPlex:: RPlex() { lo = fnc = 0; csize = DEFAULT_INITIAL_CAPACITY; * data = new [csize]; set_cache(new IChunk(data, lo, lo, fnc, lo+csize)); hd = ch; maxch = MIN_NCHUNKS; lch = maxch / 2; fch = lch + 1; base = ch->base_index() - lch * csize; chunks = new _IChunk_ptr[maxch]; chunks[lch] = ch; } RPlex:: RPlex(int chunksize) { if (chunksize == 0) error("invalid constructor specification"); lo = fnc = 0; if (chunksize > 0) { csize = chunksize; * data = new [csize]; set_cache(new IChunk(data, lo, lo, fnc, csize+lo)); hd = ch; } else { csize = -chunksize; * data = new [csize]; set_cache(new IChunk(data, chunksize+lo, lo, fnc, fnc)); hd = ch; } maxch = MIN_NCHUNKS; lch = maxch / 2; fch = lch + 1; base = ch->base_index() - lch * csize; chunks = new _IChunk_ptr[maxch]; chunks[lch] = ch; } RPlex:: RPlex(int l, int chunksize) { if (chunksize == 0) error("invalid constructor specification"); lo = fnc = l; if (chunksize > 0) { csize = chunksize; * data = new [csize]; set_cache(new IChunk(data, lo, lo, fnc, csize)); hd = ch; } else { csize = -chunksize; * data = new [csize]; set_cache(new IChunk(data, chunksize, lo, fnc, fnc)); hd = ch; } maxch = MIN_NCHUNKS; lch = maxch / 2; fch = lch + 1; base = ch->base_index() - lch * csize; chunks = new _IChunk_ptr[maxch]; chunks[lch] = ch; } void RPlex::make_initial_chunks(int up = 1) { int count = 0; int need = fnc - lo; hd = 0; if (up) { int l = lo; do { ++count; int sz; if (need >= csize) sz = csize; else sz = need; * data = new [csize]; IChunk* h = new IChunk(data, l, l, l+sz, l+csize); if (hd != 0) h->link_to_next(hd); else hd = h; l += sz; need -= sz; } while (need > 0); } else { int hi = fnc; do { ++count; int sz; if (need >= csize) sz = csize; else sz = need; * data = new [csize]; IChunk* h = new IChunk(data, hi-csize, hi-sz, hi, hi); if (hd != 0) h->link_to_next(hd); hd = h; hi -= sz; need -= sz; } while (need > 0); } set_cache((IChunk*)hd); maxch = MIN_NCHUNKS; if (maxch < count * 2) maxch = count * 2; chunks = new _IChunk_ptr[maxch]; lch = maxch / 3; fch = lch + count; base = ch->base_index() - csize * lch; int k = lch; do { chunks[k++] = ch; set_cache(ch->next()); } while (ch != hd); } RPlex:: RPlex(int l, int hi, const initval, int chunksize = 0) { lo = l; fnc = hi + 1; if (chunksize == 0) { csize = fnc - l; make_initial_chunks(1); } else if (chunksize < 0) { csize = -chunksize; make_initial_chunks(0); } else { csize = chunksize; make_initial_chunks(1); } fill(initval); } RPlex::RPlex(const RPlex& a) { lo = a.lo; fnc = a.fnc; csize = a.csize; make_initial_chunks(); for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i]; } void RPlex::operator= (const RPlex& a) { if (&a != this) { invalidate(); lo = a.lo; fnc = a.fnc; csize = a.csize; make_initial_chunks(); for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i]; } } void RPlex::cache(const * p) const { const IChunk* old = ch; const IChunk* t = ch; while (!t->actual_pointer(p)) { t = (t->next()); if (t == old) index_error(); } set_cache(t); } int RPlex::owns(Pix p) const { const IChunk* old = ch; const IChunk* t = ch; while (!t->actual_pointer(p)) { t = (t->next()); if (t == old) return 0; } set_cache(t); return 1; } * RPlex::dosucc(const * p) const { if (p == 0) return 0; const IChunk* old = ch; const IChunk* t = ch; while (!t->actual_pointer(p)) { t = (t->next()); if (t == old) return 0; } int i = t->index_of(p) + 1; if (i >= fnc) return 0; if (i >= t->fence_index()) t = (t->next()); set_cache(t); return t->pointer_to(i); } * RPlex::dopred(const * p) const { if (p == 0) return 0; const IChunk* old = ch; const IChunk* t = ch; while (!t->actual_pointer(p)) { t = (t->prev()); if (t == old) return 0; } int i = t->index_of(p) - 1; if (i < lo) return 0; if (i < t->low_index()) t = (t->prev()); set_cache(t); return (t->pointer_to(i)); } int RPlex::add_high(const elem) { IChunk* t = tl(); if (!t->can_grow_high()) { if (t->IChunk::empty() && one_chunk()) { t->clear(fnc); base = t->base_index() - lch * csize; } else { * data = new [csize]; t = (new IChunk(data, fnc, fnc, fnc,fnc+csize)); t->link_to_prev(tl()); if (fch == maxch) { maxch *= 2; IChunk** newch = new _IChunk_ptr [maxch]; bcopy(chunks, newch, fch * sizeof(_IChunk_ptr)); delete chunks; chunks = newch; } chunks[fch++] = t; } } *((t->IChunk::grow_high())) = elem; set_cache(t); return fnc++; } int RPlex::del_high () { if (empty()) empty_error(); IChunk* t = tl(); if (t->IChunk::empty()) // kill straggler first { IChunk* pred = t->prev(); del_chunk(t); t = (pred); --fch; } t->IChunk::shrink_high(); if (t->IChunk::empty() && !one_chunk()) { IChunk* pred = t->prev(); del_chunk(t); t = (pred); --fch; } set_cache(t); return --fnc - 1; } int RPlex::add_low (const elem) { IChunk* t = hd; if (!t->can_grow_low()) { if (t->IChunk::empty() && one_chunk()) { t->cleardown(lo); base = t->base_index() - lch * csize; } else { * data = new [csize]; hd = new IChunk(data, lo-csize, lo, lo, lo); hd->link_to_next(t); t = ( hd); if (lch == 0) { lch = maxch; fch += maxch; maxch *= 2; IChunk** newch = new _IChunk_ptr [maxch]; bcopy(chunks, &(newch[lch]), lch * sizeof(_IChunk_ptr)); delete chunks; chunks = newch; base = t->base_index() - (lch - 1) * csize; } chunks[--lch] = t; } } *((t->IChunk::grow_low())) = elem; set_cache(t); return --lo; } int RPlex::del_low () { if (empty()) empty_error(); IChunk* t = hd; if (t->IChunk::empty()) { hd = t->next(); del_chunk(t); t = hd; ++lch; } t->IChunk::shrink_low(); if (t->IChunk::empty() && !one_chunk()) { hd = t->next(); del_chunk(t); t = hd; ++lch; } set_cache(t); return ++lo; } void RPlex::append(const RPlex& a) { for (int i = a.low(); i < a.fence(); a.next(i)) add_high(a[i]); } void RPlex::prepend (const RPlex& a) { for (int i = a.high(); i > a.ecnef(); a.prev(i)) add_low(a[i]); } void RPlex::reverse() { tmp; int l = lo; int h = fnc - 1; IChunk* loch = hd; IChunk* hich = tl(); while (l < h) { * lptr = loch->pointer_to(l); * hptr = hich->pointer_to(h); tmp = *lptr; *lptr = *hptr; *hptr = tmp; if (++l >= loch->fence_index()) loch = loch->next(); if (--h < hich->low_index()) hich = hich->prev(); } } void RPlex::fill(const x) { for (int i = lo; i < fnc; ++i) (*this)[i] = x; } void RPlex::fill(const x, int lo, int hi) { for (int i = lo; i <= hi; ++i) (*this)[i] = x; } void RPlex::clear() { for (int i = lch + 1; i < fch; ++i) del_chunk(chunks[i]); fch = lch + 1; set_cache(chunks[lch]); ch->IChunk::clear(lo); fnc = lo; } int RPlex::reset_low(int l) { int old = lo; int diff = l - lo; if (diff != 0) { lo += diff; fnc += diff; IChunk* t = hd; do { t->re_index(t->low_index() + diff); t = t->next(); } while (t != hd); } base = hd->base_index() - lch * csize; return old; } int RPlex::OK () const { int v = hd != 0 && ch != 0; // at least one chunk v &= fnc == tl()->fence_index(); // last chunk fnc == plex fnc v &= lo == hd->IChunk::low_index(); // first lo == plex lo v &= base == hd->base_index() - lch * csize; // base is correct; v &= lch < fch; v &= fch <= maxch; // within allocation; // loop for others: int k = lch; // to cross-check nch int found_ch = 0; // to make sure ch is in list; const IChunk* t = (hd); for (;;) { v &= chunks[k++] == t; // each chunk is at proper index if (t == ch) ++found_ch; v &= t->IChunk::OK(); // each chunk is OK if (t == tl()) break; else // and has indices contiguous to succ { v &= t->top_index() == t->next()->base_index(); if (t != hd) // internal chunks full { v &= !t->empty(); v &= !t->can_grow_low(); v &= !t->can_grow_high(); } t = t->next(); } } v &= found_ch == 1; v &= fch == k; if (!v) error("invariant failure"); return v; } 0707070000020000721004440000020000020000011545610460565011400002500000014735g++-include/RPlex.hP// 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 #pragma once #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; }; 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 = 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 p) const { 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 0707070000020001021004440000020000020000011563740460565012100002600000004204g++-include/SLBag.ccP// 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. */ #include ".SLBag.h" int SLBag::OK() { int v = p.OK(); v &= count == p.length(); if (!v) error("invariant failure"); return v; } Pix SLBag::seek( item, Pix i = 0) { if (i == 0) i = first(); else next(i); for (; i != 0 && (!(EQ(p(i), item))); p.next(i)); return i; } int SLBag::nof( item) { int n = 0; for (Pix p = first(); p; next(p)) if (EQ((*this)(p), item)) ++n; return n; } void SLBag::del( item) { Pix i = p.first(); if (i == 0) return; else if (EQ(p(i), item)) { --count; p.del_front(); } else { Pix trail = i; p.next(i); while (i != 0) { if (EQ(p(i), item)) { --count; p.del_after(trail); return; } trail = i; p.next(i); } } } void SLBag::remove( item) { Pix i = p.first(); while (i != 0 && EQ(p(i), item)) { --count; p.del_front(); i = p.first(); } if (i != 0) { Pix trail = i; p.next(i); while (i != 0) { if (EQ(p(i), item)) { --count; p.del_after(trail); i = trail; p.next(i); } else { trail = i; p.next(i); } } } } 0707070000020001311004440000020000020000010230620460565012300002500000004157g++-include/SLBag.hP// 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 #pragma once #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(); }; 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 0707070000020001631004440000020000020000011656640460565012500002700000011630g++-include/SLList.ccP// 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. */ #include #include #include ".SLList.h" void SLList::error(const char* msg) { (*lib_error_handler)("SLList", msg); } SLList::SLList(SLList& a) { if (a.last == 0) last = 0; else { SLListNode* p = a.last->tl; SLListNode* h = new SLListNode(p->hd); last = h; for (;;) { if (p == a.last) { last->tl = h; return; } p = p->tl; SLListNode* n = new SLListNode(p->hd); last->tl = n; last = n; } } } SLList& SLList::operator = (SLList& a) { if (last != a.last) { clear(); if (a.last != 0) { SLListNode* p = a.last->tl; SLListNode* h = new SLListNode(p->hd); last = h; for (;;) { if (p == a.last) { last->tl = h; break; } p = p->tl; SLListNode* n = new SLListNode(p->hd); last->tl = n; last = n; } } } return *this; } void SLList::clear() { if (last == 0) return; SLListNode* p = last->tl; last->tl = 0; last = 0; while (p != 0) { SLListNode* nxt = p->tl; delete(p); p = nxt; } } Pix SLList::prepend( item) { SLListNode* t = new SLListNode(item); if (last == 0) t->tl = last = t; else { t->tl = last->tl; last->tl = t; } return Pix(t); } Pix SLList::prepend(SLListNode* t) { if (t == 0) return 0; if (last == 0) t->tl = last = t; else { t->tl = last->tl; last->tl = t; } return Pix(t); } Pix SLList::append( item) { SLListNode* t = new SLListNode(item); if (last == 0) t->tl = last = t; else { t->tl = last->tl; last->tl = t; last = t; } return Pix(t); } Pix SLList::append(SLListNode* t) { if (t == 0) return 0; if (last == 0) t->tl = last = t; else { t->tl = last->tl; last->tl = t; last = t; } return Pix(t); } void SLList::join(SLList& b) { SLListNode* t = b.last; b.last = 0; if (last == 0) last = t; else if (t != 0) { SLListNode* f = last->tl; last->tl = t->tl; t->tl = f; last = t; } } Pix SLList::ins_after(Pix p, item) { SLListNode* u = (SLListNode*)p; SLListNode* t = new SLListNode(item); if (last == 0) t->tl = last = t; else if (u == 0) // ins_after 0 means prepend { t->tl = last->tl; last->tl = t; } else { t->tl = u->tl; u->tl = t; if (u == last) last = t; } return Pix(t); } void SLList::del_after(Pix p) { SLListNode* u = (SLListNode*)p; if (last == 0 || u == last) error("cannot del_after last"); if (u == 0) u = last; // del_after 0 means delete first SLListNode* t = u->tl; if (u == t) last = 0; else { u->tl = t->tl; if (last == t) last = u; } delete t; } int SLList::owns(Pix p) { SLListNode* t = last; if (t != 0 && p != 0) { do { if (Pix(t) == p) return 1; t = t->tl; } while (t != last); } return 0; } SLList::remove_front() { if (last == 0) error("remove_front of empty list"); SLListNode* t = last->tl; res = t->hd; if (t == last) last = 0; else last->tl = t->tl; delete t; return res; } int SLList::remove_front(& x) { if (last == 0) return 0; else { SLListNode* t = last->tl; x = t->hd; if (t == last) last = 0; else last->tl = t->tl; delete t; return 1; } } void SLList::del_front() { if (last == 0) error("del_front of empty list"); SLListNode* t = last->tl; if (t == last) last = 0; else last->tl = t->tl; delete t; } int SLList::OK() { int v = 1; if (last != 0) { SLListNode* t = last; long count = MAXLONG; // Lots of chances to find last! do { count--; t = t->tl; } while (count > 0 && t != last); v &= count > 0; } if (!v) error("invariant failure"); return v; } 0707070000020002231004440000020000020000010703540460565013000002600000006575g++-include/SLList.hP// 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 #pragma once #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(); }; inline SLListNode::SLListNode() {} inline SLListNode::SLListNode( h, SLListNode* t = 0) { hd = h; tl = t; } inline SLListNode::~SLListNode() {} 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(); }; inline SLList::~SLList() { clear(); } inline SLList::SLList() { last = 0; } inline int SLList::empty() { return last == 0; } inline int SLList::length() { int l = 0; SLListNode* t = last; if (t != 0) do { ++l; t = t->tl; } while (t != last); return l; } 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 0707070000020003011004440000020000020000011146030460565013200002700000004272g++-include/SLQueue.hP// 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 #pragma once #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(); }; 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 0707070000020003561004440000020000020000010341500460565013400002600000003240g++-include/SLSet.ccP// 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. */ #include ".SLSet.h" int SLSet::OK() { int v = p.OK(); v &= count == p.length(); if (!v) error("invariant failure"); return v; } Pix SLSet::seek( item) { for (Pix i = p.first(); i != 0 && !EQ(p(i),item); p.next(i)); return i; } Pix SLSet::add( item) { Pix i = seek(item); if (i == 0) { ++count; i = p.append(item); } return i; } void SLSet::del( item) { Pix i = p.first(); if (i == 0) return; else if (EQ(p(i), item)) { --count; p.del_front(); } else { Pix trail = i; p.next(i); while (i != 0) { if (EQ(p(i), item)) { --count; p.del_after(trail); return; } trail = i; p.next(i); } } } 0707070000020003631004440000020000020000010557220460565013700002500000003724g++-include/SLSet.hP// 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 #pragma once #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(); }; 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 0707070000020003721004440000020000020000010216140460565014100002700000004302g++-include/SLStack.hP// 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 #pragma once #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(); }; 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 0707070000020004071004440000020000020000010245720460565014300002400000004652g++-include/Set.ccP// 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. */ #include #include ".Set.h" Pix Set::seek( item) { for (Pix i = first(); i != 0 && !(EQ((*this)(i), item)); next(i)); return i; } int Set::owns(Pix idx) { if (idx == 0) return 0; for (Pix i = first(); i; next(i)) if (i == idx) return 1; return 0; } void Set::clear() { Pix i = first(); while (i != 0) { del((*this)(i)); i = first(); } } int Set::contains ( item) { return seek(item) != 0; } int Set::operator <= (Set& b) { if (count > b.count) return 0; if (count == 0) return 1; for (Pix i = first(); i; next(i)) if (b.seek((*this)(i)) == 0) return 0; return 1; } int Set::operator == (Set& b) { int n = count; if (n != b.count) return 0; if (n == 0) return 1; Pix i = first(); Pix j = b.first(); while (n-- > 0) { if ((b.seek((*this)(i)) == 0) || (seek(b(j)) == 0)) return 0; next(i); b.next(j); } return 1; } int Set::operator != (Set& b) { return !(*this == b); } void Set::operator |= (Set& b) { if (&b != this) for (Pix i = b.first(); i; b.next(i)) add(b(i)); } void Set::operator -= (Set& b) { if (&b == this) clear(); else for (Pix i = b.first(); i; b.next(i)) del(b(i)); } void Set::operator &= (Set& b) { if (&b != this) { Pix i = first(); Pix n = i; while (i != 0) { next(n); if (b.seek((*this)(i)) == 0) del((*this)(i)); i = n; } } } void Set::error(const char* msg) { (*lib_error_handler)("Set", msg); } 0707070000020004371004440000020000020000011052020460565014500002300000004603g++-include/Set.hP// 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 #pragma once #define _Set_h 1 #include #include ".defs.h" class Set { protected: int count; public: 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 }; inline int Set::length() { return count; } inline int Set::empty() { return count == 0; } #endif 0707070000020004421004440000020000020000011426160460565014700003100000020336g++-include/SplayBag.ccP// 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. */ #include #include #include ".SplayBag.h" /* struct to simulate the special `null' node in the Sleater & Tarjan JACM 1985 splay tree algorithms All routines use a version of their `simple top-down' splay alg. (p 669) */ struct _dummySplayNode { SplayNode* lt; SplayNode* rt; SplayNode* par; } _dummy_null; /* traversal primitives */ SplayNode* SplayBag::leftmost() { SplayNode* t = root; if (t != 0) while (t->lt != 0) t = t->lt; return t; } SplayNode* SplayBag::rightmost() { SplayNode* t = root; if (t != 0) while (t->rt != 0) t = t->rt; return t; } SplayNode* SplayBag::succ(SplayNode* t) { if (t == 0) return 0; if (t->rt != 0) { t = t->rt; while (t->lt != 0) t = t->lt; return t; } else { for (;;) { if (t->par == 0 || t == t->par->lt) return t->par; else t = t->par; } } } SplayNode* SplayBag::pred(SplayNode* t) { if (t == 0) return 0; else if (t->lt != 0) { t = t->lt; while (t->rt != 0) t = t->rt; return t; } else { for (;;) { if (t->par == 0 || t == t->par->rt) return t->par; else t = t->par; } } } Pix SplayBag::seek( key, Pix i = 0) { if (root == 0) return 0; SplayNode* t = (SplayNode*) i; if (t != 0) { int cmp = CMP(key, t->item); if (cmp == 0) { t = succ(t); if (t != 0 && EQ(key, t->item)) return Pix(t); else return 0; } else if (cmp < 0) return 0; } t = root; int comp = CMP(key, t->item); if (comp == 0) return Pix(t); SplayNode* dummy = (SplayNode*)(&_dummy_null); SplayNode* l = dummy; SplayNode* r = dummy; dummy->rt = dummy->lt = dummy->par = 0; while (comp != 0) { if (comp > 0) { SplayNode* tr = t->rt; if (tr == 0) break; else { comp = CMP(key, tr->item); if (comp <= 0 || tr->rt == 0) { l->rt = t; t->par = l; l = t; t = tr; if (comp >= 0) break; } else { if ((t->rt = tr->lt) != 0) t->rt->par = t; tr->lt = t; t->par = tr; l->rt = tr; tr->par = l; l = tr; t = tr->rt; comp = CMP(key, t->item); } } } else { SplayNode* tl = t->lt; if (tl == 0) break; else { comp = CMP(key, tl->item); if (comp >= 0 || tl->lt == 0) { r->lt = t; t->par = r; r = t; t = tl; if (comp <= 0) break; } else { if ((t->lt = tl->rt) != 0) t->lt->par = t; tl->rt = t; t->par = tl; r->lt = tl; tl->par = r; r = tl; t = tl->lt; comp = CMP(key, t->item); } } } } if ((r->lt = t->rt) != 0) r->lt->par = r; if ((l->rt = t->lt) != 0) l->rt->par = l; if ((t->lt = dummy->rt) != 0) t->lt->par = t; if ((t->rt = dummy->lt) != 0) t->rt->par = t; t->par = 0; root = t; if (comp != 0) return 0; else { l = pred(t); while (l != 0 && EQ(l->item, key)) { t = l; l = pred(l); } return Pix(t); } } int SplayBag::nof( item) { int n = 0; SplayNode* t = (SplayNode*)(seek(item)); if (t != 0) { do { ++n; t = succ(t); } while (t != 0 && EQ(item, t->item)); } return n; } Pix SplayBag::add( item) { ++count; SplayNode* newnode = new SplayNode(item); SplayNode* t = root; if (t == 0) { root = newnode; return Pix(root); } int comp = CMP(item, t->item); SplayNode* dummy = (SplayNode*)(&_dummy_null); SplayNode* l = dummy; SplayNode* r = dummy; dummy->rt = dummy->lt = dummy->par = 0; int done = 0; while (!done) { if (comp >= 0) { SplayNode* tr = t->rt; if (tr == 0) { tr = newnode; comp = 0; done = 1; } else comp = CMP(item, tr->item); if (comp <= 0) { l->rt = t; t->par = l; l = t; t = tr; } else { SplayNode* trr = tr->rt; if (trr == 0) { trr = newnode; comp = 0; done = 1; } else comp = CMP(item, trr->item); if ((t->rt = tr->lt) != 0) t->rt->par = t; tr->lt = t; t->par = tr; l->rt = tr; tr->par = l; l = tr; t = trr; } } else { SplayNode* tl = t->lt; if (tl == 0) { tl = newnode; comp = 0; done = 1; } else comp = CMP(item, tl->item); if (comp >= 0) { r->lt = t; t->par = r; r = t; t = tl; } else { SplayNode* tll = tl->lt; if (tll == 0) { tll = newnode; comp = 0; done = 1; } else comp = CMP(item, tll->item); if ((t->lt = tl->rt) != 0) t->lt->par = t; tl->rt = t; t->par = tl; r->lt = tl; tl->par = r; r = tl; t = tll; } } } if ((r->lt = t->rt) != 0) r->lt->par = r; if ((l->rt = t->lt) != 0) l->rt->par = l; if ((t->lt = dummy->rt) != 0) t->lt->par = t; if ((t->rt = dummy->lt) != 0) t->rt->par = t; t->par = 0; root = t; return Pix(root); } void SplayBag::_del(SplayNode* t) { if (t == 0) return; SplayNode* p = t->par; --count; if (t->rt == 0) { if (t == root) { if ((root = t->lt) != 0) root->par = 0; } else if (t == p->lt) { if ((p->lt = t->lt) != 0) p->lt->par = p; } else if ((p->rt = t->lt) != 0) p->rt->par = p; } else { SplayNode* r = t->rt; SplayNode* l = r->lt; for(;;) { if (l == 0) { if (t == root) { root = r; r->par = 0; } else if (t == p->lt) { p->lt = r; r->par = p; } else { p->rt = r; r->par = p; } if ((r->lt = t->lt) != 0) r->lt->par = r; break; } else { if ((r->lt = l->rt) != 0) r->lt->par = r; l->rt = r; r->par = l; r = l; l = l->lt; } } } delete t; } void SplayBag::remove( key) { SplayNode* t = (SplayNode*)(seek(key)); while (t != 0) { _del(t); t = (SplayNode*)(seek(key)); } } void SplayBag::_kill(SplayNode* t) { if (t != 0) { _kill(t->lt); _kill(t->rt); delete t; } } SplayNode* SplayBag::_copy(SplayNode* t) { if (t != 0) { SplayNode* l = _copy(t->lt); SplayNode* r = _copy(t->rt); SplayNode* x = new SplayNode(t->item, l, r); if (l != 0) l->par = x; if (r != 0) r->par = x; return x; } else return 0; } int SplayBag::OK() { int v = 1; if (root == 0) v = count == 0; else { int n = 1; SplayNode* trail = leftmost(); SplayNode* t = succ(trail); while (t != 0) { ++n; v &= CMP(trail->item, t->item) <= 0; trail = t; t = succ(t); } v &= n == count; } if (!v) error("invariant failure"); return v; } 0707070000020004461004440000020000020000010507620460565015100003000000006307g++-include/SplayBag.hP// 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 #pragma once #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(); }; inline SplayNode::SplayNode( h, SplayNode* l=0, SplayNode* r=0) { item = h; lt = l; rt = r; par = 0; } inline SplayNode::~SplayNode() {} 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(); }; 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 0707070000020004601004440000020000020000011565640460565015300003100000017453g++-include/SplayMap.ccP// 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. */ #include #include #include "..SplayMap.h" /* struct to simulate the special `null' node in the Sleater & Tarjan JACM 1985 splay tree algorithms All routines use a version of their `simple top-down' splay alg. (p 669) */ struct _dummySplayNode { SplayNode* lt; SplayNode* rt; SplayNode* par; } _dummy_null; /* traversal primitives */ SplayNode* SplayMap::leftmost() { SplayNode* t = root; if (t != 0) while (t->lt != 0) t = t->lt; return t; } SplayNode* SplayMap::rightmost() { SplayNode* t = root; if (t != 0) while (t->rt != 0) t = t->rt; return t; } SplayNode* SplayMap::succ(SplayNode* t) { if (t == 0) return 0; if (t->rt != 0) { t = t->rt; while (t->lt != 0) t = t->lt; return t; } else { for (;;) { if (t->par == 0 || t == t->par->lt) return t->par; else t = t->par; } } } SplayNode* SplayMap::pred(SplayNode* t) { if (t == 0) return 0; else if (t->lt != 0) { t = t->lt; while (t->rt != 0) t = t->rt; return t; } else { for (;;) { if (t->par == 0 || t == t->par->rt) return t->par; else t = t->par; } } } Pix SplayMap::seek( key) { SplayNode* t = root; if (t == 0) return 0; int comp = CMP(key, t->item); if (comp == 0) return Pix(t); SplayNode* dummy = (SplayNode*)(&_dummy_null); SplayNode* l = dummy; SplayNode* r = dummy; dummy->rt = dummy->lt = dummy->par = 0; while (comp != 0) { if (comp > 0) { SplayNode* tr = t->rt; if (tr == 0) break; else { comp = CMP(key, tr->item); if (comp <= 0 || tr->rt == 0) { l->rt = t; t->par = l; l = t; t = tr; if (comp >= 0) break; } else { if ((t->rt = tr->lt) != 0) t->rt->par = t; tr->lt = t; t->par = tr; l->rt = tr; tr->par = l; l = tr; t = tr->rt; comp = CMP(key, t->item); } } } else { SplayNode* tl = t->lt; if (tl == 0) break; else { comp = CMP(key, tl->item); if (comp >= 0 || tl->lt == 0) { r->lt = t; t->par = r; r = t; t = tl; if (comp <= 0) break; } else { if ((t->lt = tl->rt) != 0) t->lt->par = t; tl->rt = t; t->par = tl; r->lt = tl; tl->par = r; r = tl; t = tl->lt; comp = CMP(key, t->item); } } } } if ((r->lt = t->rt) != 0) r->lt->par = r; if ((l->rt = t->lt) != 0) l->rt->par = l; if ((t->lt = dummy->rt) != 0) t->lt->par = t; if ((t->rt = dummy->lt) != 0) t->rt->par = t; t->par = 0; root = t; return (comp == 0) ? Pix(t) : 0; } & SplayMap::operator [] ( item) { SplayNode* t = root; if (t == 0) { ++count; root = new SplayNode(item, def); return root->cont; } int comp = CMP(item, t->item); if (comp == 0) return t->cont; SplayNode* dummy = (SplayNode*)(&_dummy_null); SplayNode* l = dummy; SplayNode* r = dummy; dummy->rt = dummy->lt = dummy->par = 0; while (comp != 0) { if (comp > 0) { SplayNode* tr = t->rt; if (tr == 0) { ++count; tr = new SplayNode(item, def); comp = 0; } else comp = CMP(item, tr->item); if (comp <= 0) { l->rt = t; t->par = l; l = t; t = tr; } else { SplayNode* trr = tr->rt; if (trr == 0) { ++count; trr = new SplayNode(item, def); comp = 0; } else comp = CMP(item, trr->item); if ((t->rt = tr->lt) != 0) t->rt->par = t; tr->lt = t; t->par = tr; l->rt = tr; tr->par = l; l = tr; t = trr; } } else { SplayNode* tl = t->lt; if (tl == 0) { ++count; tl = new SplayNode(item, def); comp = 0; } else comp = CMP(item, tl->item); if (comp >= 0) { r->lt = t; t->par = r; r = t; t = tl; } else { SplayNode* tll = tl->lt; if (tll == 0) { ++count; tll = new SplayNode(item, def); comp = 0; } else comp = CMP(item, tll->item); if ((t->lt = tl->rt) != 0) t->lt->par = t; tl->rt = t; t->par = tl; r->lt = tl; tl->par = r; r = tl; t = tll; } } } if ((r->lt = t->rt) != 0) r->lt->par = r; if ((l->rt = t->lt) != 0) l->rt->par = l; if ((t->lt = dummy->rt) != 0) t->lt->par = t; if ((t->rt = dummy->lt) != 0) t->rt->par = t; t->par = 0; root = t; return root->cont; } void SplayMap::del( key) { SplayNode* t = (SplayNode*)(seek(key)); if (t == 0) return; SplayNode* p = t->par; --count; if (t->rt == 0) { if (t == root) { if ((root = t->lt) != 0) root->par = 0; } else if (t == p->lt) { if ((p->lt = t->lt) != 0) p->lt->par = p; } else if ((p->rt = t->lt) != 0) p->rt->par = p; } else { SplayNode* r = t->rt; SplayNode* l = r->lt; for(;;) { if (l == 0) { if (t == root) { root = r; r->par = 0; } else if (t == p->lt) { p->lt = r; r->par = p; } else { p->rt = r; r->par = p; } if ((r->lt = t->lt) != 0) r->lt->par = r; break; } else { if ((r->lt = l->rt) != 0) r->lt->par = r; l->rt = r; r->par = l; r = l; l = l->lt; } } } delete t; } void SplayMap::_kill(SplayNode* t) { if (t != 0) { _kill(t->lt); _kill(t->rt); delete t; } } SplayNode* SplayMap::_copy(SplayNode* t) { if (t != 0) { SplayNode* l = _copy(t->lt); SplayNode* r = _copy(t->rt); SplayNode* x = new SplayNode(t->item, t->cont, l, r); if (l != 0) l->par = x; if (r != 0) r->par = x; return x; } else return 0; } int SplayMap::OK() { int v = 1; if (root == 0) v = count == 0; else { int n = 1; SplayNode* trail = leftmost(); SplayNode* t = succ(trail); while (t != 0) { ++n; v &= CMP(trail->item, t->item) < 0; trail = t; t = succ(t); } v &= n == count; } if (!v) error("invariant failure"); return v; } 0707070000020005031004440000020000020000010331660460565015500003000000007027g++-include/SplayMap.hP// 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 #pragma once #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(); }; inline SplayNode::SplayNode( h, c, SplayNode* l=0, SplayNode* r=0) :item(h), cont(c), lt(l), rt(r) { par = 0; } inline SplayNode::~SplayNode() {} 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(); }; 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 0707070000020005051004440000020000020000011653670460565016000003000000012004g++-include/streambuf.h// 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 _streambuf_h #pragma once #define _streambuf_h 1 /* streambufs. basic streambufs and filebufs are as in Stroustrup, ch 8, but the base class contains virtual extensions that allow most capabilities of libg++ Files to be used as streambufs via `Filebufs'. */ #include #include #include // see below for NO_LINE_BUFFER_STREAMBUFS #ifndef BUFSIZE #ifdef BUFSIZ #define BUFSIZE BUFSIZ #else #define BUFSIZE 1024 #endif #endif enum open_mode // filebuf open modes { input=0, output=1, append=2 }; class streambuf { public: char* base; // start of buffer char* pptr; // put-pointer (and gptr fence) char* gptr; // get-pointer char* eptr; // last valid addr in buffer char alloc; // true if we own freestore alloced buffer streambuf(); streambuf(char* buf, int buflen); virtual ~streambuf(); int doallocate(); int allocate(); int must_overflow(int ch); // true if should call overflow virtual int overflow(int c = EOF); // flush -- return EOF if fail virtual int underflow(); // fill -- return EOF if fail int sgetc(); // get one char (as int) or EOF int snextc(); // get and advance void stossc(); // advance only int sputback(char); // unget int sputc(int c = EOF); // write one char virtual streambuf* setbuf(char* buf, int buflen, int preloaded_count = 0); // (not virtual in AT&T) // the following aren't in AT&T version: int sputs(const char* s); // write null-terminated str int sputsn(const char* s, int len); // write len bytes virtual const char* name(); virtual streambuf* open(const char* name, open_mode m); virtual streambuf* open(const char* filename, io_mode m, access_mode a); virtual streambuf* open(const char* filename, const char* m); virtual streambuf* open(int filedesc, io_mode m); virtual streambuf* open(FILE* fileptr); virtual int is_open(); virtual int close(); virtual void error(); }; class filebuf: public streambuf { public: int fd; char opened; int overflow(int c = EOF); int underflow(); filebuf(); filebuf(int newfd); filebuf(int newfd, char* buf, int buflen); ~filebuf(); streambuf* open(const char* name, open_mode m); int is_open(); int close(); }; class Filebuf: public streambuf // libg++ File version { public: File* Fp; void init_streambuf_ptrs(); int overflow(int c = EOF); int underflow(); Filebuf(); Filebuf(const char* filename, io_mode m, access_mode a); Filebuf(const char* filename, const char* m); Filebuf(int filedesc, io_mode m); Filebuf(FILE* fileptr); ~Filebuf(); const char* name(); streambuf* setbuf(char* buf, int buflen, int preloaded_count = 0); streambuf* open(const char* filename, io_mode m, access_mode a); streambuf* open(const char* filename, const char* m); streambuf* open(int filedesc, io_mode m); streambuf* open(FILE* fileptr); int is_open(); int close(); void error(); }; inline int streambuf::must_overflow(int ch) { #ifndef NO_LINE_BUFFER_STREAMBUF return pptr >= eptr || ch == '\n'; #else return pptr >= eptr; #endif } inline int streambuf::allocate() { return (base == 0)? doallocate() : 0; } inline int streambuf::sgetc() { return (gptr >= pptr)? underflow() : int(*gptr); } inline int streambuf::snextc() { ++gptr; return (gptr >= pptr)? underflow() : int(*gptr); } inline void streambuf::stossc() { if (gptr >= pptr) underflow(); else gptr++; } inline int streambuf::sputback(char ch) { return (gptr > base)? (*--gptr = ch) : EOF; } inline int streambuf::sputc(int ch) { return must_overflow(ch)? overflow(ch) : (*pptr++ = char(ch)); } #endif 0707070000020005601004440000020000020000010607210460565016200002700000006132g++-include/SplayPQ.hP// 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 #pragma once #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(); }; inline SplayNode::SplayNode( h, SplayNode* l=0, SplayNode* r=0) { item = h; lt = l; rt = r; par = 0; } inline SplayNode::~SplayNode() {} 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 }; 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 0707070000020006301004440000020000020000010345410460565016400003100000022207g++-include/SplaySet.ccP// 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. */ #include #include #include ".SplaySet.h" /* struct to simulate the special `null' node in the Sleater & Tarjan JACM 1985 splay tree algorithms All routines use a version of their `simple top-down' splay alg. (p 669) */ struct _dummySplayNode { SplayNode* lt; SplayNode* rt; SplayNode* par; } _dummy_null; /* traversal primitives */ SplayNode* SplaySet::leftmost() { SplayNode* t = root; if (t != 0) while (t->lt != 0) t = t->lt; return t; } SplayNode* SplaySet::rightmost() { SplayNode* t = root; if (t != 0) while (t->rt != 0) t = t->rt; return t; } SplayNode* SplaySet::succ(SplayNode* t) { if (t == 0) return 0; if (t->rt != 0) { t = t->rt; while (t->lt != 0) t = t->lt; return t; } else { for (;;) { if (t->par == 0 || t == t->par->lt) return t->par; else t = t->par; } } } SplayNode* SplaySet::pred(SplayNode* t) { if (t == 0) return 0; else if (t->lt != 0) { t = t->lt; while (t->rt != 0) t = t->rt; return t; } else { for (;;) { if (t->par == 0 || t == t->par->rt) return t->par; else t = t->par; } } } Pix SplaySet::seek( key) { SplayNode* t = root; if (t == 0) return 0; int comp = CMP(key, t->item); if (comp == 0) return Pix(t); SplayNode* dummy = (SplayNode*)(&_dummy_null); SplayNode* l = dummy; SplayNode* r = dummy; dummy->rt = dummy->lt = dummy->par = 0; while (comp != 0) { if (comp > 0) { SplayNode* tr = t->rt; if (tr == 0) break; else { comp = CMP(key, tr->item); if (comp <= 0 || tr->rt == 0) { l->rt = t; t->par = l; l = t; t = tr; if (comp >= 0) break; } else { if ((t->rt = tr->lt) != 0) t->rt->par = t; tr->lt = t; t->par = tr; l->rt = tr; tr->par = l; l = tr; t = tr->rt; comp = CMP(key, t->item); } } } else { SplayNode* tl = t->lt; if (tl == 0) break; else { comp = CMP(key, tl->item); if (comp >= 0 || tl->lt == 0) { r->lt = t; t->par = r; r = t; t = tl; if (comp <= 0) break; } else { if ((t->lt = tl->rt) != 0) t->lt->par = t; tl->rt = t; t->par = tl; r->lt = tl; tl->par = r; r = tl; t = tl->lt; comp = CMP(key, t->item); } } } } if ((r->lt = t->rt) != 0) r->lt->par = r; if ((l->rt = t->lt) != 0) l->rt->par = l; if ((t->lt = dummy->rt) != 0) t->lt->par = t; if ((t->rt = dummy->lt) != 0) t->rt->par = t; t->par = 0; root = t; return (comp == 0) ? Pix(t) : 0; } Pix SplaySet::add( item) { SplayNode* t = root; if (t == 0) { ++count; root = new SplayNode(item); return Pix(root); } int comp = CMP(item, t->item); if (comp == 0) return Pix(t); SplayNode* dummy = (SplayNode*)(&_dummy_null); SplayNode* l = dummy; SplayNode* r = dummy; dummy->rt = dummy->lt = dummy->par = 0; while (comp != 0) { if (comp > 0) { SplayNode* tr = t->rt; if (tr == 0) { ++count; tr = new SplayNode(item); comp = 0; } else comp = CMP(item, tr->item); if (comp <= 0) { l->rt = t; t->par = l; l = t; t = tr; } else { SplayNode* trr = tr->rt; if (trr == 0) { ++count; trr = new SplayNode(item); comp = 0; } else comp = CMP(item, trr->item); if ((t->rt = tr->lt) != 0) t->rt->par = t; tr->lt = t; t->par = tr; l->rt = tr; tr->par = l; l = tr; t = trr; } } else { SplayNode* tl = t->lt; if (tl == 0) { ++count; tl = new SplayNode(item); comp = 0; } else comp = CMP(item, tl->item); if (comp >= 0) { r->lt = t; t->par = r; r = t; t = tl; } else { SplayNode* tll = tl->lt; if (tll == 0) { ++count; tll = new SplayNode(item); comp = 0; } else comp = CMP(item, tll->item); if ((t->lt = tl->rt) != 0) t->lt->par = t; tl->rt = t; t->par = tl; r->lt = tl; tl->par = r; r = tl; t = tll; } } } if ((r->lt = t->rt) != 0) r->lt->par = r; if ((l->rt = t->lt) != 0) l->rt->par = l; if ((t->lt = dummy->rt) != 0) t->lt->par = t; if ((t->rt = dummy->lt) != 0) t->rt->par = t; t->par = 0; root = t; return Pix(root); } void SplaySet::del( key) { SplayNode* t = (SplayNode*)(seek(key)); if (t == 0) return; SplayNode* p = t->par; --count; if (t->rt == 0) { if (t == root) { if ((root = t->lt) != 0) root->par = 0; } else if (t == p->lt) { if ((p->lt = t->lt) != 0) p->lt->par = p; } else if ((p->rt = t->lt) != 0) p->rt->par = p; } else { SplayNode* r = t->rt; SplayNode* l = r->lt; for(;;) { if (l == 0) { if (t == root) { root = r; r->par = 0; } else if (t == p->lt) { p->lt = r; r->par = p; } else { p->rt = r; r->par = p; } if ((r->lt = t->lt) != 0) r->lt->par = r; break; } else { if ((r->lt = l->rt) != 0) r->lt->par = r; l->rt = r; r->par = l; r = l; l = l->lt; } } } delete t; } void SplaySet::_kill(SplayNode* t) { if (t != 0) { _kill(t->lt); _kill(t->rt); delete t; } } SplayNode* SplaySet::_copy(SplayNode* t) { if (t != 0) { SplayNode* l = _copy(t->lt); SplayNode* r = _copy(t->rt); SplayNode* x = new SplayNode(t->item, l, r); if (l != 0) l->par = x; if (r != 0) r->par = x; return x; } else return 0; } /* relationals */ int SplaySet::operator == (SplaySet& y) { if (count != y.count) return 0; else { SplayNode* t = leftmost(); SplayNode* u = y.leftmost(); for (;;) { if (t == 0) return 1; else if (!EQ(t->item, u->item)) return 0; else { t = succ(t); u = y.succ(u); } } } } int SplaySet::operator <= (SplaySet& y) { if (count > y.count) return 0; else { SplayNode* t = leftmost(); SplayNode* u = y.leftmost(); for (;;) { if (t == 0) return 1; else if (u == 0) return 0; int cmp = CMP(t->item, u->item); if (cmp == 0) { t = succ(t); u = y.succ(u); } else if (cmp < 0) return 0; else u = y.succ(u); } } } void SplaySet::operator |=(SplaySet& y) { if (&y == this) return; SplayNode* u = y.leftmost(); while (u != 0) { add(u->item); u = y.succ(u); } } void SplaySet::operator &= (SplaySet& y) { if (y.count == 0) clear(); else if (&y != this && count != 0) { SplayNode* t = leftmost(); while (t != 0) { SplayNode* s = succ(t); if (y.seek(t->item) == 0) del(t->item); t = s; } } } void SplaySet::operator -=(SplaySet& y) { if (&y == this) clear(); else if (y.count != 0) { SplayNode* t = leftmost(); while (t != 0) { SplayNode* s = succ(t); if (y.seek(t->item) != 0) del(t->item); t = s; } } } int SplaySet::OK() { int v = 1; if (root == 0) v = count == 0; else { int n = 1; SplayNode* trail = leftmost(); SplayNode* t = succ(trail); while (t != 0) { ++n; v &= CMP(trail->item, t->item) < 0; trail = t; t = succ(t); } v &= n == count; } if (!v) error("invariant failure"); return v; } 0707070000020006311004440000020000020000011415310460565016600003000000006614g++-include/SplaySet.hP// 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 #pragma once #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(); }; inline SplayNode::SplayNode( h, SplayNode* l=0, SplayNode* r=0) { item = h; lt = l; rt = r; par = 0; } inline SplayNode::~SplayNode() {} 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(); }; 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 0707070000020006321004440000020000020000010561630460565017000002200000001345g++-include/new.h#ifndef _new_h #pragma once #define _new_h 1 #include #include #ifndef NO_LIBGXX_MALLOC #define MALLOC_ALIGN_MASK 7 /* ptrs aligned at 8 byte boundaries */ #define MALLOC_MIN_OVERHEAD 8 /* 8 bytes of overhead per pointer */ #endif typedef void (*new_handler_t)(); extern "C" void default_new_handler(); extern "C" new_handler_t set_new_handler(new_handler_t); #ifdef __GNUG__ #define NEW(where) new { where } #endif // default placement version of operator new static inline void *operator new(size_t, void *place) { return place; } // provide a C++ interface to vector-resize via realloc static inline void *operator new(size_t size, void *ptr, size_t new_len) { return realloc(ptr, new_len * size); } #endif 0707070000020007571004440000020000020000011360260460565017300002500000003237g++-include/Stack.hP// 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 #pragma once #define _Stack_h #include #include ".defs.h" class Stack { public: Stack(); ~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; }; inline Stack::Stack() {} inline Stack::~Stack() {} inline void Stack::error(const char* msg) { (*lib_error_handler)("Stack", msg); } #endif 0707070000020007621004440000020000020000011527360460565017500002600000014152g++-include/VHBag.ccP// 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. */ #include ".VHBag.h" /* codes for status fields */ #define EMPTYCELL 0 #define VALIDCELL 1 #define DELETEDCELL 2 VHBag::VHBag(unsigned int sz = DEFAULT_INITIAL_CAPACITY) { tab = new [size = sz]; status = new char[size]; for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = 0; } VHBag::VHBag(VHBag& a) { tab = new [size = a.size]; status = new char[size]; for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = 0; for (Pix p = a.first(); p; a.next(p)) add(a(p)); } /* * hashing method: double hash based on high bits of hash fct, * followed by linear probe. Can't do too much better if table * sizes not constrained to be prime. */ static inline unsigned int doublehashinc(unsigned int h, unsigned int s) { return ((h / s) % s) >? 1; } Pix VHBag::seek( key, Pix p = 0) { * t = (*) p; if (t == 0 || !EQ(*t, key)) { unsigned int hashval = HASH(key); unsigned int h = hashval % size; for (unsigned int i = 0; i <= size; ++i) { if (status[h] == EMPTYCELL) return 0; else if (status[h] == VALIDCELL && EQ(key, tab[h])) return Pix(&tab[h]); if (i == 0) h = (h + doublehashinc(hashval, size)) % size; else if (++h >= size) h -= size; } return 0; } else { int seent = 0; unsigned int hashval = HASH(key); unsigned int h = hashval % size; for (unsigned int i = 0; i <= size; ++i) { if (status[h] == EMPTYCELL) return 0; else if (&tab[h] == t) seent = 1; else if (seent && status[h] == VALIDCELL && EQ(key, tab[h])) return Pix(&tab[h]); if (i == 0) h = (h + doublehashinc(hashval, size)) % size; else if (++h >= size) h -= size; } return 0; } } int VHBag::nof( item) { int n = 0; unsigned int hashval = HASH(item); unsigned int h = hashval % size; unsigned int firsth = size; for (unsigned int i = 0; i <= size; ++i) { if (status[h] == EMPTYCELL) return n; else if (h != firsth && status[h] == VALIDCELL && EQ(item, tab[h])) { ++n; if (firsth >= size) firsth = h; } if (i == 0) h = (h + doublehashinc(hashval, size)) % size; else if (++h >= size) h -= size; } return n; } Pix VHBag::add( item) { if (size <= count + 1) resize(); unsigned int bestspot = size; unsigned int hashval = HASH(item); unsigned int h = hashval % size; for (unsigned int i = 0; i <= size; ++i) { if (status[h] == EMPTYCELL) { if (bestspot >= size) bestspot = h; tab[bestspot] = item; status[bestspot] = VALIDCELL; ++count; return Pix(&tab[bestspot]); } else if (status[h] == DELETEDCELL) { if (bestspot >= size) bestspot = h; } if (i == 0) h = (h + doublehashinc(hashval, size)) % size; else if (++h >= size) h -= size; } tab[bestspot] = item; status[bestspot] = VALIDCELL; ++count; return Pix(&tab[bestspot]); } void VHBag::del( key) { unsigned int hashval = HASH(key); unsigned int h = hashval % size; for (unsigned int i = 0; i <= size; ++i) { if (status[h] == EMPTYCELL) return; else if (status[h] == VALIDCELL && EQ(key, tab[h])) { status[h] = DELETEDCELL; --count; return; } if (i == 0) h = (h + doublehashinc(hashval, size)) % size; else if (++h >= size) h -= size; } } void VHBag::remove( key) { unsigned int hashval = HASH(key); unsigned int h = hashval % size; for (unsigned int i = 0; i <= size; ++i) { if (status[h] == EMPTYCELL) return; else if (status[h] == VALIDCELL && EQ(key, tab[h])) { status[h] = DELETEDCELL; --count; } if (i == 0) h = (h + doublehashinc(hashval, size)) % size; else if (++h >= size) h -= size; } } void VHBag::clear() { for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = 0; } void VHBag::resize(unsigned int newsize = 0) { if (newsize <= count) { newsize = DEFAULT_INITIAL_CAPACITY; while (newsize <= count) newsize <<= 1; } * oldtab = tab; char* oldstatus = status; unsigned int oldsize = size; tab = new [size = newsize]; status = new char[size]; for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = 0; for (i = 0; i < oldsize; ++i) if (oldstatus[i] == VALIDCELL) add(oldtab[i]); delete [oldsize] oldtab; delete oldstatus; } Pix VHBag::first() { for (unsigned int pos = 0; pos < size; ++pos) if (status[pos] == VALIDCELL) return Pix(&tab[pos]); return 0; } void VHBag::next(Pix& i) { if (i == 0) return; unsigned int pos = ((unsigned)i - (unsigned)tab) / sizeof() + 1; for (; pos < size; ++pos) if (status[pos] == VALIDCELL) { i = Pix(&tab[pos]); return; } i = 0; } int VHBag::OK() { int v = tab != 0; v &= status != 0; int n = 0; for (unsigned int i = 0; i < size; ++i) { if (status[i] == VALIDCELL) ++n; else if (status[i] != DELETEDCELL && status[i] != EMPTYCELL) v = 0; } v &= n == count; if (!v) error("invariant failure"); return v; } 0707070000020010161004440000020000020000011003120460565017700002500000003740g++-include/VHBag.hP// 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 #pragma once #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(); }; 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 0707070000020010171004440000020000020000011006350460565020200002600000011657g++-include/VHMap.ccP// 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. */ #include "..VHMap.h" /* codes for status fields */ #define EMPTYCELL 0 #define VALIDCELL 1 #define DELETEDCELL 2 VHMap::VHMap( dflt, unsigned int sz = DEFAULT_INITIAL_CAPACITY) :(dflt) { tab = new [size = sz]; cont = new [size]; status = new char[size]; for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; } VHMap::VHMap(VHMap& a) : (a.def) { tab = new [size = a.size]; cont = new [size]; status = new char[size]; for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = 0; for (Pix p = a.first(); p; a.next(p)) (*this)[a.key(p)] = a.contents(p); } /* * hashing method: double hash based on high bits of hash fct, * followed by linear probe. Can't do too much better if table * sizes not constrained to be prime. */ static inline unsigned int doublehashinc(unsigned int h, unsigned int s) { return ((h / s) % s) >? 1; } Pix VHMap::seek( key) { unsigned int hashval = HASH(key); unsigned int h = hashval % size; for (unsigned int i = 0; i <= size; ++i) { if (status[h] == EMPTYCELL) return 0; else if (status[h] == VALIDCELL && EQ(key, tab[h])) return Pix(&tab[h]); if (i == 0) h = (h + doublehashinc(hashval, size)) % size; else if (++h >= size) h -= size; } return 0; } & VHMap::operator []( item) { if (size <= count + 1) resize(); unsigned int bestspot = size; unsigned int hashval = HASH(item); unsigned int h = hashval % size; for (unsigned int i = 0; i <= size; ++i) { if (status[h] == EMPTYCELL) { ++count; if (bestspot >= size) bestspot = h; tab[bestspot] = item; status[bestspot] = VALIDCELL; cont[bestspot] = def; return cont[bestspot]; } else if (status[h] == DELETEDCELL) { if (bestspot >= size) bestspot = h; } else if (EQ(tab[h],item)) return cont[h]; if (i == 0) h = (h + doublehashinc(hashval, size)) % size; else if (++h >= size) h -= size; } ++count; status[bestspot] = VALIDCELL; tab[bestspot] = item; cont[bestspot] = def; return cont[bestspot]; } void VHMap::del( key) { unsigned int hashval = HASH(key); unsigned int h = hashval % size; for (unsigned int i = 0; i <= size; ++i) { if (status[h] == EMPTYCELL) return; else if (status[h] == VALIDCELL && EQ(key, tab[h])) { status[h] = DELETEDCELL; --count; return; } if (i == 0) h = (h + doublehashinc(hashval, size)) % size; else if (++h >= size) h -= size; } } void VHMap::clear() { for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = 0; } void VHMap::resize(unsigned int newsize = 0) { if (newsize <= count) { newsize = DEFAULT_INITIAL_CAPACITY; while (newsize <= count) newsize <<= 1; } * oldtab = tab; * oldcont = cont; char* oldstatus = status; unsigned int oldsize = size; tab = new [size = newsize]; cont = new [size]; status = new char[size]; for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = 0; for (i = 0; i < oldsize; ++i) if (oldstatus[i] == VALIDCELL) (*this)[oldtab[i]] = oldcont[i]; delete [oldsize] oldtab; delete [oldsize] oldcont; delete oldstatus; } Pix VHMap::first() { for (unsigned int pos = 0; pos < size; ++pos) if (status[pos] == VALIDCELL) return Pix(&tab[pos]); return 0; } void VHMap::next(Pix& i) { if (i == 0) return; unsigned int pos = ((unsigned)i - (unsigned)tab) / sizeof() + 1; for (; pos < size; ++pos) if (status[pos] == VALIDCELL) { i = Pix(&tab[pos]); return; } i = 0; } int VHMap::OK() { int v = tab != 0; v &= status != 0; int n = 0; for (unsigned int i = 0; i < size; ++i) { if (status[i] == VALIDCELL) ++n; else if (status[i] != DELETEDCELL && status[i] != EMPTYCELL) v = 0; } v &= n == count; if (!v) error("invariant failure"); return v; } 0707070000020010211004440000020000020000010766130460565020400002500000004115g++-include/VHMap.hP// 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 #pragma once #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(); }; 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 0707070000020010301004440000020000020000010207030460565020600002600000013531g++-include/VHSet.ccP// 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. */ #include ".VHSet.h" /* codes for status fields */ #define EMPTYCELL 0 #define VALIDCELL 1 #define DELETEDCELL 2 VHSet::VHSet(unsigned int sz = DEFAULT_INITIAL_CAPACITY) { tab = new [size = sz]; status = new char[size]; for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = 0; } VHSet::VHSet(VHSet& a) { tab = new [size = a.size]; status = new char[size]; for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = 0; for (Pix p = a.first(); p; a.next(p)) add(a(p)); } /* * hashing method: double hash based on high bits of hash fct, * followed by linear probe. Can't do too much better if table * sizes not constrained to be prime. */ static inline unsigned int doublehashinc(unsigned int h, unsigned int s) { return ((h / s) % s) >? 1; } Pix VHSet::seek( key) { unsigned int hashval = HASH(key); unsigned int h = hashval % size; for (unsigned int i = 0; i <= size; ++i) { if (status[h] == EMPTYCELL) return 0; else if (status[h] == VALIDCELL && EQ(key, tab[h])) return Pix(&tab[h]); if (i == 0) h = (h + doublehashinc(hashval, size)) % size; else if (++h >= size) h -= size; } return 0; } Pix VHSet::add( item) { if (size <= count + 1) resize(); unsigned int bestspot = size; unsigned int hashval = HASH(item); unsigned int h = hashval % size; for (unsigned int i = 0; i <= size; ++i) { if (status[h] == EMPTYCELL) { if (bestspot >= size) bestspot = h; tab[bestspot] = item; status[bestspot] = VALIDCELL; ++count; return Pix(&tab[bestspot]); } else if (status[h] == DELETEDCELL) { if (bestspot >= size) bestspot = h; } else if (EQ(tab[h],item)) return Pix(&tab[h]); if (i == 0) h = (h + doublehashinc(hashval, size)) % size; else if (++h >= size) h -= size; } tab[bestspot] = item; status[bestspot] = VALIDCELL; ++count; return Pix(&tab[bestspot]); } void VHSet::del( key) { unsigned int hashval = HASH(key); unsigned int h = hashval % size; for (unsigned int i = 0; i <= size; ++i) { if (status[h] == EMPTYCELL) return; else if (status[h] == VALIDCELL && EQ(key, tab[h])) { status[h] = DELETEDCELL; --count; return; } if (i == 0) h = (h + doublehashinc(hashval, size)) % size; else if (++h >= size) h -= size; } } void VHSet::clear() { for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = 0; } void VHSet::resize(unsigned int newsize = 0) { if (newsize <= count) { newsize = DEFAULT_INITIAL_CAPACITY; while (newsize <= count) newsize <<= 1; } * oldtab = tab; char* oldstatus = status; unsigned int oldsize = size; tab = new [size = newsize]; status = new char[size]; for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = 0; for (i = 0; i < oldsize; ++i) if (oldstatus[i] == VALIDCELL) add(oldtab[i]); delete [oldsize] oldtab; delete oldstatus; } Pix VHSet::first() { for (unsigned int pos = 0; pos < size; ++pos) if (status[pos] == VALIDCELL) return Pix(&tab[pos]); return 0; } void VHSet::next(Pix& i) { if (i == 0) return; unsigned int pos = ((unsigned)i - (unsigned)tab) / sizeof() + 1; for (; pos < size; ++pos) if (status[pos] == VALIDCELL) { i = Pix(&tab[pos]); return; } i = 0; } int VHSet:: operator == (VHSet& b) { if (count != b.count) return 0; else { for (unsigned int i = 0; i < size; ++i) if (status[i] == VALIDCELL && b.seek(tab[i]) == 0) return 0; for (i = 0; i < b.size; ++i) if (b.status[i] == VALIDCELL && seek(b.tab[i]) == 0) return 0; return 1; } } int VHSet::operator <= (VHSet& b) { if (count > b.count) return 0; else { for (unsigned int i = 0; i < size; ++i) if (status[i] == VALIDCELL && b.seek(tab[i]) == 0) return 0; return 1; } } void VHSet::operator |= (VHSet& b) { if (&b == this || b.count == 0) return; for (unsigned int i = 0; i < b.size; ++i) if (b.status[i] == VALIDCELL) add(b.tab[i]); } void VHSet::operator &= (VHSet& b) { if (&b == this || count == 0) return; for (unsigned int i = 0; i < size; ++i) { if (status[i] == VALIDCELL && b.seek(tab[i]) == 0) { status[i] = DELETEDCELL; --count; } } } void VHSet::operator -= (VHSet& b) { for (unsigned int i = 0; i < size; ++i) { if (status[i] == VALIDCELL && b.seek(tab[i]) != 0) { status[i] = DELETEDCELL; --count; } } } int VHSet::OK() { int v = tab != 0; v &= status != 0; int n = 0; for (unsigned int i = 0; i < size; ++i) { if (status[i] == VALIDCELL) ++n; else if (status[i] != DELETEDCELL && status[i] != EMPTYCELL) v = 0; } v &= n == count; if (!v) error("invariant failure"); return v; } 0707070000020010341004440000020000020000011574560460565021000002500000004346g++-include/VHSet.hP// 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 #pragma once #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(); }; 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 0707070000020010351004440000020000020000010337170460565021200002700000016233g++-include/VOHSet.ccP// 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. */ #include #include ".VOHSet.h" /* codes for status fields */ #define EMPTYCELL 0 #define VALIDCELL 1 #define DELETEDCELL 2 VOHSet::VOHSet(int sz = DEFAULT_INITIAL_CAPACITY) { // The size of the hash table is always the smallest power of 2 >= the size // indicated by the user. This allows several optimizations, including // the use of actual double hashing and elimination of the mod instruction. size = 1; while (size < sz) size <<= 1; tab = new [size]; status = new char[size]; for (int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = cnt = 0; } VOHSet::VOHSet(VOHSet& a) { tab = new [size = a.size]; status = new char[size]; for (int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = cnt = 0; for (Pix p = a.first(); p; a.next(p)) add(a(p)); } Pix VOHSet::seek( key) { // Uses ordered double hashing to perform a search of the table. // This greatly speeds up the average-case time for an unsuccessful search. unsigned hashval = HASH(key); // We can avoid the mod operation since size is a power of 2. unsigned h = hashval & (size - 1); // The increment must be odd, since all odd numbers are relatively // prime to a power of 2!! unsigned inc = ((((hashval / size) << 1) + 1) & (size - 1)); // There is always at least 1 empty cell, so this loop is guaranteed to halt! while (status[h] != EMPTYCELL) { int cmp = CMP (key, tab[h]); if (cmp == 0) { if (status[h] == VALIDCELL) return Pix(&tab[h]); else return 0; } else if (cmp > 0) return 0; else h = ((h + inc) & (size - 1)); } return 0; } // This adds an item if it doesn't already exist. By performing the initial // comparison we assure that the table always contains at least 1 empty // spot. This speeds up later searching by a constant factor. // The insertion algorithm uses ordered double hashing. See Standish's // 1980 ``Data Structure's Techniques'' book for details. Pix VOHSet::add( x) { if (size <= cnt+1) resize(); unsigned hashval = HASH(x); unsigned h = hashval & (size - 1); if (status[h] != VALIDCELL) // save some work if possible { if (status[h] == EMPTYCELL) cnt++; count++; tab[h] = x; status[h] = VALIDCELL; return Pix(&tab[h]); } int cmp = CMP(x, tab[h]); if (cmp == 0) return Pix(&tab[h]); item = x; Pix mypix = 0; unsigned inc = ((((hashval / size) << 1) + 1) & (size - 1)); for (;;) { if (cmp < 0) { temp = tab[h]; tab[h] = item; item = temp; if (mypix == 0) mypix = Pix(&tab[h]); inc = ((((HASH(item) / size) << 1) + 1) & (size - 1)); h = ((h + inc) & (size - 1)); cmp = CMP(item, tab[h]); } else h = ((h + inc) & (size - 1)); if (status[h] != VALIDCELL) { if (status[h] == EMPTYCELL) cnt++; count++; tab[h] = item; status[h] = VALIDCELL; return (mypix == 0)? Pix(&tab[h]) : mypix; } } } void VOHSet::del( key) { // This performs a deletion by marking the item's status field. // Note that we only decrease the count, *not* the cnt, since this // would cause trouble for subsequent steps in the algorithm. See // Reingold and Hanson's ``Data Structure's'' book for a justification // of this approach. unsigned hashval = HASH(key); unsigned h = hashval & (size - 1); unsigned inc = ((((hashval / size) << 1) + 1) & (size - 1)); while (status[h] != EMPTYCELL) { int cmp = CMP(key, tab[h]); if (cmp < 0) h = ((h + inc) & (size - 1)); else if (status[h] == VALIDCELL && cmp == 0) { status[h] = DELETEDCELL; count--; return; } else return; } } void VOHSet::clear() { for (int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = cnt = 0; } void VOHSet::resize(int newsize = 0) { if (newsize <= count) newsize = count; int s = 1; while (s <= newsize) s <<= 1; newsize = s; * oldtab = tab; char* oldstatus = status; int oldsize = size; tab = new [size = newsize]; status = new char[size]; for (int i = 0; i < size; ++i) status[i] = EMPTYCELL; count = cnt = 0; for (i = 0; i < oldsize; ++i) if (oldstatus[i] == VALIDCELL) add(oldtab[i]); delete [oldsize] oldtab; delete oldstatus; } Pix VOHSet::first() { for (int pos = 0; pos < size; ++pos) if (status[pos] == VALIDCELL) return Pix(&tab[pos]); return 0; } void VOHSet::next(Pix& i) { if (i == 0) return; int pos = ((unsigned)i - (unsigned)tab) / sizeof() + 1; for (; pos < size; ++pos) if (status[pos] == VALIDCELL) { i = Pix(&tab[pos]); return; } i = 0; } int VOHSet:: operator == (VOHSet& b) { if (count != b.count) return 0; else { for (int i = 0; i < size; ++i) if (status[i] == VALIDCELL && b.seek(tab[i]) == 0) return 0; for (i = 0; i < b.size; ++i) if (b.status[i] == VALIDCELL && seek(b.tab[i]) == 0) return 0; return 1; } } int VOHSet:: operator != (VOHSet& b) { return !(*this == b); } int VOHSet::operator <= (VOHSet& b) { if (count > b.count) return 0; else { for (int i = 0; i < size; ++i) if (status[i] == VALIDCELL && b.seek(tab[i]) == 0) return 0; return 1; } } void VOHSet::operator |= (VOHSet& b) { if (&b == this || b.count == 0) return; for (int i = 0; i < b.size; ++i) if (b.status[i] == VALIDCELL) add(b.tab[i]); } void VOHSet::operator &= (VOHSet& b) { if (&b == this || count == 0) return; for (int i = 0; i < size; ++i) { if (status[i] == VALIDCELL && b.seek(tab[i]) == 0) { status[i] = DELETEDCELL; --count; } } } void VOHSet::operator -= (VOHSet& b) { for (int i = 0; i < size; ++i) { if (status[i] == VALIDCELL && b.seek(tab[i]) != 0) { status[i] = DELETEDCELL; --count; } } } int VOHSet::OK() { int v = tab != 0; v &= status != 0; int n = 0; for (int i = 0; i < size; ++i) { if (status[i] == VALIDCELL) ++n; else if (status[i] != DELETEDCELL && status[i] != EMPTYCELL) v = 0; } v &= n == count; if (!v) error("invariant failure"); return v; } 0707070000020011061004440000020000020000011621760460565021400002600000004364g++-include/VOHSet.hP// 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 #pragma once #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(); }; 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 0707070000020011101004440000020000020000011045510460565021600002700000004163g++-include/VQueue.ccP// 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. */ #include #include ".VQueue.h" VQueue::VQueue(VQueue& b) :size(b.size), cnt(b.cnt), inp(b.inp), outp(b.outp), s(new [b.size]) { int j = outp; for (int i = 0; i < cnt; ++i) { s[j] = b.s[j]; if (++j == size) j = 0; } } void VQueue::operator = (VQueue& b) { if (&b == this) return; if (size != b.size) { delete [size] s; s = new [b.size]; size = b.size; } inp = b.inp; outp = b.outp; cnt = b.cnt; int j = outp; for (int i = 0; i < cnt; ++i) { s[j] = b.s[j]; if (++j == size) j = 0; } } void VQueue::resize(int newsz) { if (newsz < cnt) error("resize: new size too small"); * news = new [newsz]; int j = outp; for (int i = 0; i < cnt; ++i) { news[i] = s[j]; if (++j == size) j = 0; } inp = j; outp = 0; delete [size] s; s = news; size = newsz; } int VQueue::OK() { int v = s != 0; // have space v &= size >= 0; // a legal size v &= inp >= 0 && inp <= size; // pointers with bounds v &= outp >= 0 && outp <= size; int c = (size + inp - outp) % size; v &= cnt == size || cnt == c; // correct count if (!v) error("invariant failure"); return v; } 0707070000020011211004440000020000020000011346170460565022000002600000005366g++-include/VQueue.hP// 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 #pragma once #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(); }; inline VQueue::VQueue(int sz = DEFAULT_INITIAL_CAPACITY) { 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 0707070000020011311004440000020000020000011445740460565022300002700000003437g++-include/VStack.ccP// 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. */ #include #include ".VStack.h" // error handling VStack::VStack(VStack& b) :size(b.size), ptr(b.ptr), s(new [b.size]) { for (int i = 0; i < ptr; ++i) s[i] = b.s[i]; } void VStack::operator = (VStack& b) { if (&b == this) return; if (size < b.ptr) { delete [size] s; s = new [b.size]; size = b.size; } ptr = b.ptr; for (int i = 0; i < ptr; ++i) s[i] = b.s[i]; } void VStack::resize(int newsz) { if (newsz < ptr) error("resize: new size too small"); * news = new [newsz]; for (int i = 0; i < ptr; ++i) news[i] = s[i]; delete [size] s; s = news; size = newsz; } int VStack::OK() { int v = s != 0; // have space v &= size >= 0; // a legal size v &= ptr <= size; // ptr within bounds v &= ptr >= 0; if (!v) error("invariant failure"); return v; } 0707070000020011341004440000020000020000010110110460565022600002600000005026g++-include/VStack.hP// 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 #pragma once #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(); }; inline VStack::VStack(int sz = DEFAULT_INITIAL_CAPACITY) { 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 0707070000020012331004440000020000020000010770710460565023000002400000027120g++-include/Fix24.h// This may look like C code, but it is really -*- C++ -*- /* Copyright (C) 1988 Free Software Foundation written by Kurt Baudendistel (gt-eedsp!baud@gatech.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 _Fix24_h #pragma once #define _Fix24_h 1 #include #include // extra type definitions typedef struct { long u; unsigned long l; } twolongs; // constant definitions extern const double Fix24_fs, Fix24_mult, Fix24_div, Fix24_max, Fix24_min; extern const unsigned long Fix24_msb, Fix24_lsb, Fix24_m_max, Fix24_m_min; extern const double Fix48_fs, Fix48_max, Fix48_min, Fix48_div_u, Fix48_div_l; extern const twolongs Fix48_msb, Fix48_lsb, Fix48_m_max, Fix48_m_min; // // Fix24 class: 24-bit Fixed point data type // // consists of a 24-bit mantissa (sign bit & 23 data bits). // class Fix24 { friend class Fix48; long m; long assign(double d); operator double(); Fix24(long i); Fix24(int i); public: Fix24(); Fix24(Fix24& f); Fix24(double d); Fix24(Fix48& f); ~Fix24(); Fix24& operator=(Fix24& f); Fix24& operator=(double d); Fix24& operator=(Fix48& f); friend long& mantissa(Fix24& f); friend double value(Fix24& f); Fix24 operator + (); Fix24 operator - (); friend Fix24 operator + (Fix24& f, Fix24& g); friend Fix24 operator - (Fix24& f, Fix24& g); friend Fix48 operator * (Fix24& f, Fix24& g); friend Fix24 operator * (Fix24& f, int g); friend Fix24 operator * (int g, Fix24& f); friend Fix24 operator / (Fix24& f, Fix24& g); friend Fix24 operator << (Fix24& f, int b); friend Fix24 operator >> (Fix24& f, int b); Fix24& operator += (Fix24& f); Fix24& operator -= (Fix24& f); Fix24& operator *= (Fix24& f); Fix24& operator *= (int b); Fix24& operator /= (Fix24& f); Fix24& operator <<=(int b); Fix24& operator >>=(int b); friend int operator == (Fix24& f, Fix24& g); friend int operator != (Fix24& f, Fix24& g); friend int operator >= (Fix24& f, Fix24& g); friend int operator <= (Fix24& f, Fix24& g); friend int operator > (Fix24& f, Fix24& g); friend int operator < (Fix24& f, Fix24& g); friend istream& operator >> (istream& s, Fix24& f); friend ostream& operator << (ostream& s, Fix24& f); void overflow(long&); void range_error(long&); }; // // Fix48 class: 48-bit Fixed point data type // // consists of a 48-bit mantissa (sign bit & 47 data bits). // class Fix48 { friend class Fix24; twolongs m; twolongs assign(double d); operator double(); Fix48(twolongs i); public: Fix48(); Fix48(Fix48& f); Fix48(Fix24& f); Fix48(double d); ~Fix48(); Fix48& operator = (Fix48& f); Fix48& operator = (Fix24& f); Fix48& operator = (double d); friend twolongs& mantissa(Fix48& f); friend double value(Fix48& f); Fix48 operator + (); Fix48 operator - (); friend Fix48 operator + (Fix48& f, Fix48& g); friend Fix48 operator - (Fix48& f, Fix48& g); friend Fix48 operator * (Fix48& f, int g); friend Fix48 operator * (int g, Fix48& f); friend Fix48 operator << (Fix48& f, int b); friend Fix48 operator >> (Fix48& f, int b); friend Fix48 operator * (Fix24& f, Fix24& g); Fix48& operator += (Fix48& f); Fix48& operator -= (Fix48& f); Fix48& operator *= (int b); Fix48& operator <<=(int b); Fix48& operator >>=(int b); friend int operator == (Fix48& f, Fix48& g); friend int operator != (Fix48& f, Fix48& g); friend int operator >= (Fix48& f, Fix48& g); friend int operator <= (Fix48& f, Fix48& g); friend int operator > (Fix48& f, Fix48& g); friend int operator < (Fix48& f, Fix48& g); friend istream& operator >> (istream& s, Fix48& f); friend ostream& operator << (ostream& s, Fix48& f); void overflow(twolongs& i); void range_error(twolongs& i); }; inline Fix24::~Fix24() {} inline Fix24::Fix24(long i) { m = i; } inline Fix24::Fix24(int i) { m = i; } inline Fix24::operator double() { return Fix24_div * m; } inline Fix24::Fix24() { m = 0; } inline Fix24::Fix24(Fix24& f) { m = f.m; } inline Fix24::Fix24(double d) { m = assign(d); } inline Fix24::Fix24(Fix48& f) { m = f.m.u; } inline Fix24& Fix24::operator=(Fix24& f) { m = f.m; return *this; } inline Fix24& Fix24::operator=(double d) { m = assign(d); return *this; } inline Fix24& Fix24::operator=(Fix48& f) { m = f.m.u; return *this; } inline long& mantissa(Fix24& f) { return f.m; } inline double value(Fix24& f) { return double(f); } inline Fix24 Fix24::operator+() { return m; } inline Fix24 Fix24::operator-() { return -m; } inline Fix24 operator+(Fix24& f, Fix24& g) { long sum = f.m + g.m; if ( (f.m ^ sum) & (g.m ^ sum) & Fix24_msb ) f.overflow(sum); return sum; } inline Fix24 operator-(Fix24& f, Fix24& g) { long sum = f.m - g.m; if ( (f.m ^ sum) & (-g.m ^ sum) & Fix24_msb ) f.overflow(sum); return sum; } inline Fix24 operator*(Fix24& a, int b) { return a.m * b; } inline Fix24 operator*(int b, Fix24& a) { return a * b; } inline Fix24 operator<<(Fix24& a, int b) { return a.m << b; } inline Fix24 operator>>(Fix24& a, int b) { return (a.m >> b) & 0xffffff00L; } inline Fix24& Fix24:: operator+=(Fix24& f) { return *this = *this + f; } inline Fix24& Fix24:: operator-=(Fix24& f) { return *this = *this - f; } inline Fix24& Fix24::operator*=(Fix24& f) { return *this = *this * f; } inline Fix24& Fix24:: operator/=(Fix24& f) { return *this = *this / f; } inline Fix24& Fix24:: operator<<=(int b) { return *this = *this << b; } inline Fix24& Fix24:: operator>>=(int b) { return *this = *this >> b; } inline Fix24& Fix24::operator*=(int b) { return *this = *this * b; } inline int operator==(Fix24& f, Fix24& g) { return f.m == g.m; } inline int operator!=(Fix24& f, Fix24& g) { return f.m != g.m; } inline int operator>=(Fix24& f, Fix24& g) { return f.m >= g.m; } inline int operator<=(Fix24& f, Fix24& g) { return f.m <= g.m; } inline int operator>(Fix24& f, Fix24& g) { return f.m > g.m; } inline int operator<(Fix24& f, Fix24& g) { return f.m < g.m; } inline istream& operator>>(istream& s, Fix24& f) { double d; s >> d; f = d; return s; } inline ostream& operator<<(ostream& s, Fix24& f) { return s << double(f); } inline Fix48::~Fix48() {} inline Fix48::Fix48(twolongs i) { m = i; } inline Fix48:: operator double() { /* * Note: can't simply do Fix48_div_u * m.u + Fix48_div_l * m.l, because * m.u is signed and m.l is unsigned. */ return (m.u >= 0)? Fix48_div_u * m.u + Fix48_div_l * m.l : (Fix48_div_u * ((unsigned long)(m.u & 0xffffff00)) + Fix48_div_l * m.l) - 2; } inline Fix48::Fix48() { m.u = 0; m.l = 0; } inline Fix48::Fix48(Fix48& f) { m = f.m; } inline Fix48::Fix48(Fix24& f) { m.u = f.m; m.l = 0; } inline Fix48::Fix48(double d) { m = assign(d); } inline Fix48& Fix48::operator=(Fix48& f) { m = f.m; return *this; } inline Fix48& Fix48::operator=(Fix24& f) { m.u = f.m; m.l = 0; return *this; } inline Fix48& Fix48::operator=(double d) { m = assign(d); return *this; } inline twolongs& mantissa(Fix48& f) { return f.m; } inline double value(Fix48& f) { return double(f); } inline Fix48 Fix48::operator+() { return m; } inline Fix48 Fix48::operator-() { twolongs n; n.l = -m.l; n.u = ~m.u + ((n.l ^ m.l) & Fix24_msb ? 0 : Fix24_lsb); return Fix48(n); } inline Fix48 operator*(int b, Fix48& a) { return a * b; } inline Fix48& Fix48::operator+=(Fix48& f) { return *this = *this + f; } inline Fix48& Fix48::operator-=(Fix48& f) { return *this = *this - f; } inline Fix48& Fix48::operator*=(int b) { return *this = *this * b; } inline Fix48& Fix48::operator<<=(int b) { return *this = *this << b; } inline Fix48& Fix48::operator>>=(int b) { return *this = *this >> b; } inline int operator==(Fix48& f, Fix48& g) { return f.m.u == g.m.u && f.m.l == g.m.l; } inline int operator!=(Fix48& f, Fix48& g) { return f.m.u != g.m.u || f.m.l != g.m.l; } inline int operator>=(Fix48& f, Fix48& g) { return f.m.u >= g.m.u || (f.m.u == g.m.u && f.m.l >= g.m.l); } inline int operator<=(Fix48& f, Fix48& g) { return f.m.u <= g.m.u || (f.m.u == g.m.u && f.m.l <= g.m.l); } inline int operator>(Fix48& f, Fix48& g) { return f.m.u > g.m.u || (f.m.u == g.m.u && f.m.l > g.m.l); } inline int operator<(Fix48& f, Fix48& g) { return f.m.u < g.m.u || (f.m.u == g.m.u && f.m.l < g.m.l); } inline istream& operator>>(istream& s, Fix48& f) { double d; s >> d; f = d; return s; } inline ostream& operator<<(ostream& s, Fix48& f) { return s << double(f); } // active error handler declarations typedef void (*Fix24_peh)(long&); typedef void (*Fix48_peh)(twolongs&); extern Fix24_peh Fix24_overflow_handler; extern Fix48_peh Fix48_overflow_handler; extern Fix24_peh Fix24_range_error_handler; extern Fix48_peh Fix48_range_error_handler; // error handler declarations extern Fix24_peh set_Fix24_overflow_handler(Fix24_peh); extern Fix48_peh set_Fix48_overflow_handler(Fix48_peh); extern void set_overflow_handler(Fix24_peh, Fix48_peh); extern Fix24_peh set_Fix24_range_error_handler(Fix24_peh); extern Fix48_peh set_Fix48_range_error_handler(Fix48_peh); extern void set_range_error_handler(Fix24_peh, Fix48_peh); extern void Fix24_ignore(long&), Fix24_overflow_saturate(long&), Fix24_overflow_warning_saturate(long&), Fix24_warning(long&), Fix24_abort(long&); extern void Fix48_ignore(twolongs&), Fix48_overflow_saturate(twolongs&), Fix48_overflow_warning_saturate(twolongs&), Fix48_warning(twolongs&), Fix48_abort(twolongs&); #endif 0707070000020012421004440000020000020000011077210460565023200002300000007744g++-include/Vec.hP// 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 #pragma once #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(); }; inline Vec::Vec() { len = 0; s = 0; } inline Vec::Vec(int l) { s = new [len = l]; } inline Vec::Vec(int l, fill_value) { s = new [len = l]; * top = &(s[len]); * t = s; while (t < top) *t++ = fill_value; } inline Vec::Vec(int l, * d) { len = l; s = d; } inline Vec::Vec(Vec& v) { s = new [len = v.len]; * top = &(s[len]); * t = s; * u = v.s; while (t < top) *t++ = *u++; } inline Vec::~Vec() { delete[len] s; } inline Vec& Vec::operator = (Vec& v) { if (this != &v) { delete[len] s; s = new [len = v.len]; * top = &(s[len]); * t = s; * u = v.s; while (t < top) *t++ = *u++; } return *this; } 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 void Vec::apply(Procedure f) { * top = &(s[len]); * t = s; while (t < top) (*f)(*t++); } inline int operator != (Vec& a, Vec& b) { return !(a == b); } 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); #endif 0707070000020012531004440000020000020000010621250460565023400002600000003373g++-include/XPBag.ccP// 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. */ #include ".XPBag.h" int XPBag::OK() { int v = p.OK(); v &= count == p.length(); if (!v) error("invariant failure"); return v; } Pix XPBag::seek( item, Pix i = 0) { if (i == 0) i = p.first(); else next(i); for (; i != 0; p.next(i)) if (EQ(p(i), item)) return i; return 0; } int XPBag::nof( item) { int n = 0; for (int i = p.low(); i < p.fence(); p.next(i)) if (EQ(p[i], item)) ++n; return n; } void XPBag::del( item) { for (int i = p.low(); i < p.fence(); p.next(i)) { if (EQ(p[i], item)) { --count; p[i] = p.low_element(); p.del_low(); return; } } } void XPBag::remove( item) { for (int i = p.low(); i < p.fence(); p.next(i)) { if (EQ(p[i], item)) { --count; p[i] = p.low_element(); p.del_low(); } } } 0707070000020012611004440000020000020000011627720460565023600002500000004347g++-include/XPBag.hP// 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 #pragma once #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(); }; inline XPBag::XPBag(int chunksize = DEFAULT_INITIAL_CAPACITY) : 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 0707070000020012621004440000020000020000011530500460565024000002700000005314g++-include/XPDeque.hP// 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 #pragma once #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(); }; inline XPDeque::XPDeque(int chunksize = DEFAULT_INITIAL_CAPACITY) : 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 0707070000020012741004440000020000020000011501650460565024200002500000005635g++-include/XPPQ.ccP// 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. */ #include ".XPPQ.h" int XPPQ::OK() { int v = p.OK(); v &= p.low() == 1; v &= count == p.length(); if (!v) error("invariant failure"); return v; } Pix XPPQ::seek( item) { for (int i = p.low(); i < p.fence(); p.next(i)) if (EQ(p[i],item)) return p.index_to_Pix(i); return 0; } // standard 2-ary heap ops // pointers are used a lot to avoid thrashing across chunks with plexes Pix XPPQ::enq( item) { p.add_high(item); * pk = &(p.high_element()); int par = ++count >> 1; while (par != 0) { * ppar = &(p[par]); if (!(LE(*ppar, item))) { *pk = *ppar; pk = ppar; par >>= 1; } else break; } *pk = item; return Pix(pk); } void XPPQ::del_front() { if (count == 0) error("empty PQ"); --count; * pk = &(p.low_element()); * ph = &(p.high_element()); int child = 2; while (child <= count) { * pchild = &(p[child]); if (child < count) { * prchild = &(p[child+1]); if (!(LE(*pchild, *prchild))) { pchild = prchild; ++child; } } if (!(LE(*ph, *pchild))) { *pk = *pchild; pk = pchild; child <<= 1; } else break; } *pk = *ph; p.del_high(); } void XPPQ::del(Pix i) { if (i == 0) error("null Pix"); --count; int k = p.Pix_to_index(i); * pk = &(p[k]); * ph = &(p.high_element()); int child = k << 1; while (child <= count) { * pchild = &(p[child]); if (child < count) { * prchild = &(p[child+1]); if (!(LE(*pchild, *prchild))) { pchild = prchild; ++child; } } if (!(LE(*ph, *pchild))) { *pk = *pchild; pk = pchild; child <<= 1; } else break; } int par = child >> 2; while (par != 0) { * ppar = &(p[par]); if (!(LE(*ppar, *ph))) { *pk = *ppar; pk = ppar; par >>= 1; } else break; } *pk = *ph; p.del_high(); } 0707070000020012751004440000020000020000011250260460565024400002400000004457g++-include/XPPQ.hP// 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 #pragma once #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 }; inline XPPQ::XPPQ(int chunksize = DEFAULT_INITIAL_CAPACITY) : 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 0707070000020013271004440000020000020000010734760460565024600002700000004624g++-include/XPQueue.hP// 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 #pragma once #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(); }; inline XPQueue::XPQueue(int chunksize = DEFAULT_INITIAL_CAPACITY) : 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 0707070000020013321004440000020000020000011247020460565025000002600000003057g++-include/XPSet.ccP// 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. */ #include ".XPSet.h" int XPSet::OK() { int v = p.OK(); v &= count == p.length(); if (!v) error("invariant failure"); return v; } Pix XPSet::seek( item) { for (int i = p.low(); i < p.fence(); p.next(i)) if (EQ(p[i],item)) return p.index_to_Pix(i); return 0; } Pix XPSet::add( item) { Pix i = seek(item); if (i == 0) { ++count; i = p.index_to_Pix(p.add_high(item)); } return i; } void XPSet::del( item) { for (int i = p.low(); i < p.fence(); p.next(i)) { if (EQ(p[i], item)) { --count; p[i] = p.low_element(); p.del_low(); return; } } } 0707070000020013331004440000020000020000010472700460565025200002500000004072g++-include/XPSet.hP// 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 #pragma once #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(); }; inline XPSet::XPSet(int chunksize = DEFAULT_INITIAL_CAPACITY) : 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 0707070000020013351004440000020000020000010714520460565025400002700000004622g++-include/XPStack.hP// 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 #pragma once #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(); }; inline XPStack::XPStack(int chunksize = DEFAULT_INITIAL_CAPACITY) : 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 0707070000020013431004440000020000020000011570330460565025700002600000020256g++-include/XPlex.ccP// 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. */ #include ".XPlex.h" XPlex:: XPlex() { lo = fnc = 0; csize = DEFAULT_INITIAL_CAPACITY; * data = new [csize]; set_cache(new IChunk(data, lo, lo, fnc, lo+csize)); hd = ch; } XPlex:: XPlex(int chunksize) { if (chunksize == 0) error("invalid constructor specification"); lo = fnc = 0; if (chunksize > 0) { csize = chunksize; * data = new [csize]; set_cache(new IChunk(data, lo, lo, fnc, csize)); hd = ch; } else { csize = -chunksize; * data = new [csize]; set_cache(new IChunk(data, chunksize, lo, fnc, fnc)); hd = ch; } } XPlex:: XPlex(int l, int chunksize) { if (chunksize == 0) error("invalid constructor specification"); lo = fnc = l; if (chunksize > 0) { csize = chunksize; * data = new [csize]; set_cache(new IChunk(data, lo, lo, fnc, csize+lo)); hd = ch; } else { csize = -chunksize; * data = new [csize]; set_cache(new IChunk(data, chunksize+lo, lo, fnc, fnc)); hd = ch; } } void XPlex::make_initial_chunks(int up = 1) { int need = fnc - lo; hd = 0; if (up) { int l = lo; do { int sz; if (need >= csize) sz = csize; else sz = need; * data = new [csize]; IChunk* h = new IChunk(data, l, l, l+sz, l+csize); if (hd != 0) h->link_to_next(hd); else hd = h; l += sz; need -= sz; } while (need > 0); } else { int hi = fnc; do { int sz; if (need >= csize) sz = csize; else sz = need; * data = new [csize]; IChunk* h = new IChunk(data, hi-csize, hi-sz, hi, hi); if (hd != 0) h->link_to_next(hd); hd = h; hi -= sz; need -= sz; } while (need > 0); } set_cache(hd); } XPlex:: XPlex(int l, int hi, const initval, int chunksize = 0) { lo = l; fnc = hi + 1; if (chunksize == 0) { csize = fnc - l; make_initial_chunks(1); } else if (chunksize < 0) { csize = -chunksize; make_initial_chunks(0); } else { csize = chunksize; make_initial_chunks(1); } fill(initval); } XPlex::XPlex(const XPlex& a) { lo = a.lo; fnc = a.fnc; csize = a.csize; make_initial_chunks(); for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i]; } void XPlex::operator= (const XPlex& a) { if (&a != this) { invalidate(); lo = a.lo; fnc = a.fnc; csize = a.csize; make_initial_chunks(); for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i]; } } void XPlex::cache(int idx) const { const IChunk* tail = tl(); const IChunk* t = ch; while (idx >= t->fence_index()) { if (t == tail) index_error(); t = (t->next()); } while (idx < t->low_index()) { if (t == hd) index_error(); t = (t->prev()); } set_cache(t); } void XPlex::cache(const * p) const { const IChunk* old = ch; const IChunk* t = ch; while (!t->actual_pointer(p)) { t = (t->next()); if (t == old) index_error(); } set_cache(t); } int XPlex::owns(Pix p) const { const IChunk* old = ch; const IChunk* t = ch; while (!t->actual_pointer(p)) { t = (t->next()); if (t == old) { set_cache(t); return 0; } } set_cache(t); return 1; } * XPlex::dosucc(const * p) const { if (p == 0) return 0; const IChunk* old = ch; const IChunk* t = ch; while (!t->actual_pointer(p)) { t = (t->next()); if (t == old) return 0; } int i = t->index_of(p) + 1; if (i >= fnc) return 0; if (i >= t->fence_index()) t = (t->next()); set_cache(t); return (t->pointer_to(i)); } * XPlex::dopred(const * p) const { if (p == 0) return 0; const IChunk* old = ch; const IChunk* t = ch; while (!t->actual_pointer(p)) { t = (t->prev()); if (t == old) return 0; } int i = t->index_of(p) - 1; if (i < lo) return 0; if (i < t->low_index()) t = (t->prev()); set_cache(t); return (t->pointer_to(i)); } int XPlex::add_high(const elem) { IChunk* t = tl(); if (!t->can_grow_high()) { if (t->IChunk::empty() && one_chunk()) t->clear(fnc); else { * data = new [csize]; t = (new IChunk(data, fnc, fnc, fnc,fnc+csize)); t->link_to_prev(tl()); } } *((t->IChunk::grow_high())) = elem; set_cache(t); return fnc++; } int XPlex::del_high () { if (empty()) empty_error(); IChunk* t = tl(); t->IChunk::shrink_high(); if (t->IChunk::empty() && !one_chunk()) { IChunk* pred = t->prev(); del_chunk(t); t = pred; } set_cache(t); return --fnc - 1; } int XPlex::add_low (const elem) { IChunk* t = hd; if (!t->can_grow_low()) { if (t->IChunk::empty() && one_chunk()) t->cleardown(lo); else { * data = new [csize]; hd = new IChunk(data, lo-csize, lo, lo, lo); hd->link_to_next(t); t = hd; } } *((t->IChunk::grow_low())) = elem; set_cache(t); return --lo; } int XPlex::del_low () { if (empty()) empty_error(); IChunk* t = hd; t->IChunk::shrink_low(); if (t->IChunk::empty() && !one_chunk()) { hd = t->next(); del_chunk(t); t = hd; } set_cache(t); return ++lo; } void XPlex::append (const XPlex& a) { for (int i = a.low(); i < a.fence(); a.next(i)) add_high(a[i]); } void XPlex::prepend (const XPlex& a) { for (int i = a.high(); i > a.ecnef(); a.prev(i)) add_low(a[i]); } void XPlex::reverse() { tmp; int l = lo; int h = fnc - 1; IChunk* loch = hd; IChunk* hich = tl(); while (l < h) { * lptr = loch->pointer_to(l); * hptr = hich->pointer_to(h); tmp = *lptr; *lptr = *hptr; *hptr = tmp; if (++l >= loch->fence_index()) loch = loch->next(); if (--h < hich->low_index()) hich = hich->prev(); } } void XPlex::fill(const x) { for (int i = lo; i < fnc; ++i) (*this)[i] = x; } void XPlex::fill(const x, int l, int hi) { for (int i = l; i <= hi; ++i) (*this)[i] = x; } void XPlex::clear() { if (fnc != lo) { IChunk* t = tl(); while (t != hd) { IChunk* prv = t->prev(); del_chunk(t); t = prv; } t->IChunk::clear(lo); set_cache(t); fnc = lo; } } int XPlex::OK () const { int v = hd != 0 && ch != 0; // at least one chunk v &= fnc == tl()->fence_index();// last chunk fence == plex fence v &= lo == ((hd))->IChunk::low_index(); // first lo == plex lo // loop for others: int found_ch = 0; // to make sure ch is in list; const IChunk* t = (hd); for (;;) { if (t == ch) ++found_ch; v &= t->IChunk::OK(); // each chunk is OK if (t == tl()) break; else // and has indices contiguous to succ { v &= t->top_index() == t->next()->base_index(); if (t != hd) // internal chunks full { v &= !t->empty(); v &= !t->can_grow_low(); v &= !t->can_grow_high(); } t = t->next(); } } v &= found_ch == 1; if (!v) error("invariant failure"); return v; } 0707070000020013461004440000020000020000011051020460565026100002500000013747g++-include/XPlex.hP// 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 #pragma once #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; }; 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 p) const { 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 = t; } #endif 0707070000020013541004440000020000020000011375340460565026300002400000003002g++-include/defs.hP// 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 _defs_h #pragma once #define _defs_h 1 // equality operator #ifndef EQ #define EQ(a, b) ((a) == (b)) #endif // less-than-or-equal #ifndef LE #define LE(a, b) ((a) <= (b)) #endif // comparison : less-than -> < 0; equal -> 0; greater-than -> > 0 #ifndef CMP #define CMP(a, b) ( ((a) <= (b))? (((a) == (b))? 0 : -1) : 1 ) #endif // hash function #ifndef HASH extern unsigned int hash(); #define HASH(x) hash(x) #endif // initial capacity for structures requiring one #ifndef DEFAULT_INITIAL_CAPACITY #define DEFAULT_INITIAL_CAPACITY 100 #endif #endif 0707070000020013671004440000020000020000010726770460565026600003300000022236g++-include/CursesWindow.h// This may look like C code, but it is really -*- C++ -*- /* Copyright (C) 1989 Free Software Foundation written by Eric Newton (newton@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 _CursesWindow_h #pragma once #define _CursesWindow_h #pragma once #include /* * * C++ class for windows. * * */ class CursesWindow { protected: static int count; // count of all active windows: // We rely on the c++ promise that // all otherwise uninitialized // static class vars are set to 0 WINDOW * w; // the curses WINDOW int alloced; // true if we own the WINDOW CursesWindow* par; // parent, if subwindow CursesWindow* subwins; // head of subwindows list CursesWindow* sib; // next subwindow of parent void kill_subwindows(); // disable all subwindows public: CursesWindow(WINDOW* &window); // useful only for stdscr CursesWindow(int lines, // number of lines int cols, // number of columns int begin_y, // line origin int begin_x); // col origin CursesWindow(CursesWindow& par, // parent window int lines, // number of lines int cols, // number of columns int by, // absolute or relative int bx, // origins: char absrel = 'a'); // if `a', by & bx are // absolute screen pos, // else if `r', they are // relative to par origin ~CursesWindow(); // terminal status int lines(); // number of lines on terminal, *not* window int cols(); // number of cols on terminal, *not* window // window status int height(); // number of lines in this window int width(); // number of cols in this window int begx(); // smallest x coord in window int begy(); // smallest y coord in window int maxx(); // largest x coord in window int maxy(); // largest x coord in window // window positioning int move(int y, int x); // coordinate positioning void getyx(int& y, int& x); int mvcur(int sy, int ey, int sx, int ex); // input int getch(); int getstr(char * str); int scanw(const char *, ...); // input + positioning int mvgetch(int y, int x); int mvgetstr(int y, int x, char * str); int mvscanw(int, int, const char*, ...); // output int addch(const char ch); int addstr(const char * str); int printw(const char * fmt, ...); int inch(); int insch(char c); int insertln(); // output + positioning int mvaddch(int y, int x, char ch); int mvaddstr(int y, int x, char * str); int mvprintw(int y, int x, const char * fmt, ...); int mvinch(int y, int x); int mvinsch(int y, int x, char ch); // borders int box(char vert, char hor); // erasure int erase(); int clear(); int clearok(cbool bf); int clrtobot(); int clrtoeol(); int delch(); int mvdelch(int y, int x); int deleteln(); // screen control int scroll(); int scrollok(cbool bf); int touchwin(); int touchline(int y, int sx, int ex); int refresh(); int leaveok(cbool bf); int flushok(cbool bf); int standout(); int standend(); // multiple window control int overlay(CursesWindow &win); int overwrite(CursesWindow &win); #ifndef DGUX int touchoverlap(CursesWindow &win); #endif // traversal support CursesWindow* child(); CursesWindow* sibling(); CursesWindow* parent(); }; inline int CursesWindow::begx() { return w->_begx; } inline int CursesWindow::begy() { return w->_begy; } inline int CursesWindow::maxx() { return w->_maxx; } inline int CursesWindow::maxy() { return w->_maxy; } inline int CursesWindow::height() { return maxy() - begy() + 1; } inline int CursesWindow::width() { return maxx() - begx() + 1; } inline int CursesWindow::box(char vert, char hor) { return ::box(w, vert, hor); } inline int CursesWindow::overlay(CursesWindow &win) { return ::overlay(w, win.w); } inline int CursesWindow::overwrite(CursesWindow &win) { return ::overwrite(w, win.w); } inline int CursesWindow::scroll() { return ::scroll(w); } #ifndef DGUX inline int CursesWindow::touchoverlap(CursesWindow &win) { return ::touchoverlap(w, win.w); } #endif inline int CursesWindow::touchwin() { return ::touchwin(w); } inline int CursesWindow::addch(const char ch) { return ::waddch(w, ch); } inline int CursesWindow::addstr(const char * str) { return ::waddstr(w, str); } inline int CursesWindow::clear() { return ::wclear(w); } inline int CursesWindow::clrtobot() { return ::wclrtobot(w); } inline int CursesWindow::clrtoeol() { return ::wclrtoeol(w); } inline int CursesWindow::delch() { return ::wdelch(w); } inline int CursesWindow::deleteln() { return ::wdeleteln(w); } inline int CursesWindow::erase() { return ::werase(w); } inline int CursesWindow::getch() { return ::wgetch(w); } inline int CursesWindow::getstr(char * str) { return ::wgetstr(w, str); } inline int CursesWindow::inch() { return winch(w); } inline int CursesWindow::insch(char c) { return ::winsch(w, c); } inline int CursesWindow::insertln() { return ::winsertln(w); } inline int CursesWindow::move(int y, int x) { return ::wmove(w, y, x); } inline int CursesWindow::touchline(int y, int sx, int ex) { return ::touchline(w, y, sx, ex); } inline int CursesWindow::mvcur(int sy, int ey, int sx, int ex) { return ::mvcur(sy, ey, sx,ex); } inline int CursesWindow::mvaddch(int y, int x, char ch) { return (::wmove(w, y, x)==0) ? 0 : ::waddch(w, ch); } inline int CursesWindow::mvgetch(int y, int x) { return (::wmove(w, y, x)==0) ? 0 : ::wgetch(w); } inline int CursesWindow::mvaddstr(int y, int x, char * str) { return (::wmove(w, y, x)==0) ? 0 : ::waddstr(w, str); } inline int CursesWindow::mvgetstr(int y, int x, char * str) { return (::wmove(w, y, x)==0) ? 0 : ::wgetstr(w, str); } inline int CursesWindow::mvinch(int y, int x) { return (::wmove(w, y, x)==0) ? 0 : ::winch(w); } inline int CursesWindow::mvdelch(int y, int x) { return (::wmove(w, y, x)==0) ? 0 : ::wdelch(w); } inline int CursesWindow::mvinsch(int y, int x, char ch) { return (::wmove(w, y, x)==0) ? 0 : ::winsch(w, ch); } inline int CursesWindow::refresh() { return ::wrefresh(w); } inline int CursesWindow::clearok(cbool bf) { return ::clearok(w,bf); } inline int CursesWindow::leaveok(cbool bf) { return ::leaveok(w,bf); } inline int CursesWindow::scrollok(cbool bf) { return ::scrollok(w,bf); } inline int CursesWindow::flushok(cbool bf) { return ::flushok(w, bf); } inline void CursesWindow::getyx(int& y, int& x) { ::getyx(w, y, x); } inline int CursesWindow::standout() { return ::wstandout(w); } inline int CursesWindow::standend() { return ::wstandend(w); } inline int CursesWindow::lines() { return LINES; } inline int CursesWindow::cols() { return COLS; } inline CursesWindow* CursesWindow::child() { return subwins; } inline CursesWindow* CursesWindow::parent() { return par; } inline CursesWindow* CursesWindow::sibling() { return sib; } # endif 0707070000020013701004440000020000020000011066120460565027000002500000004071g++-include/signal.h// This may look like C code, but it is really -*- C++ -*- /* Copyright (C) 1989 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 _signal_h #pragma once extern "C" { // This #define KERNEL hack gets around bad function prototypes on most // systems. If not, you need to do some real work... #define KERNEL #include #undef KERNEL #ifndef _signal_h #define _signal_h 1 #endif // The Interviews folks call this SignalHandler. Might as well conform. // Beware: some systems think that SignalHandler returns int. typedef void (*SignalHandler) (...); extern SignalHandler signal(int sig, SignalHandler action); extern SignalHandler sigset(int sig, SignalHandler action); extern SignalHandler ssignal(int sig, SignalHandler action); extern int gsignal (int sig); extern int kill (int pid, int sig); #ifndef hpux // Interviews folks claim that hpux doesn't like these extern int sigsetmask(int mask); extern int sigblock(int mask); extern int sigpause(int mask); extern int sigvec(int sig, struct sigvec* v, struct sigvec* prev); #endif // The Interviews version also has these ... #define SignalBad ((SignalHandler)-1) #define SignalDefault ((SignalHandler)0) #define SignalIgnore ((SignalHandler)1) } #endif 0707070000020014011004440000020000020000010513500460565027200003100000020402g++-include/math-68881.h/******************************************************************\ * * * last modified: 18 May 1989. * * * * Copyright (C) 1989 by Matthew Self. * * You may freely distribute verbatim copies of this software * * provided that this copyright notice is retained in all copies. * * You may distribute modifications to this software under the * * conditions above if you also clearly note such modifications * * with their author and date. * * * * Note: errno is not set to EDOM when domain errors occur for * * most of these functions. Rather, it is assumed that the * * 68881's OPERR exception will be enabled and handled * * appropriately by the operating system. Similarly, overflow * * and underflow do not set errno to ERANGE. * * * * Send bugs to Matthew Self (self@bayes.arc.nasa.gov). * * * \******************************************************************/ #include #ifndef HUGE_VAL #define HUGE_VAL \ ({ \ double huge_val; \ \ __asm ("fmove%.d #0x7ff0000000000000,%0" /* Infinity */ \ : "=f" (huge_val) \ : /* no inputs */); \ huge_val; \ }) #endif __inline static const double sin (double x) { double value; __asm ("fsin%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double cos (double x) { double value; __asm ("fcos%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double tan (double x) { double value; __asm ("ftan%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double asin (double x) { double value; __asm ("fasin%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double acos (double x) { double value; __asm ("facos%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double atan (double x) { double value; __asm ("fatan%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double atan2 (double y, double x) { double pi, pi_over_2; __asm ("fmovecr%.x %#0,%0" /* extended precision pi */ : "=f" (pi) : /* no inputs */ ); __asm ("fscale%.b %#-1,%0" /* no loss of accuracy */ : "=f" (pi_over_2) : "0" (pi)); if (x > 0) { if (y > 0) { if (x > y) return atan (y / x); else return pi_over_2 - atan (x / y); } else { if (x > -y) return atan (y / x); else return - pi_over_2 - atan (x / y); } } else { if (y > 0) { if (-x > y) return pi + atan (y / x); else return pi_over_2 - atan (x / y); } else { if (-x > -y) return - pi + atan (y / x); else if (y < 0) return - pi_over_2 - atan (x / y); else { double value; errno = EDOM; __asm ("fmove%.d %#0rnan,%0" /* quiet NaN */ : "=f" (value) : /* no inputs */); return value; } } } } __inline static const double sinh (double x) { double value; __asm ("fsinh%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double cosh (double x) { double value; __asm ("fcosh%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double tanh (double x) { double value; __asm ("ftanh%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double atanh (double x) { double value; __asm ("fatanh%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double exp (double x) { double value; __asm ("fetox%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double expm1 (double x) { double value; __asm ("fetoxm1%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double log (double x) { double value; __asm ("flogn%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double log1p (double x) { double value; __asm ("flognp1%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double log10 (double x) { double value; __asm ("flog10%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double sqrt (double x) { double value; __asm ("fsqrt%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double pow (const double x, const double y) { if (x > 0) return exp (y * log (x)); else if (x == 0) { if (y > 0) return 0.0; else { double value; errno = EDOM; __asm ("fmove%.d %#0rnan,%0" /* quiet NaN */ : "=f" (value) : /* no inputs */); return value; } } else { double temp; __asm ("fintrz%.x %1,%0" : "=f" (temp) /* integer-valued float */ : "f" (y)); if (y == temp) { int i = (int) y; if ((i & 1) == 0) /* even */ return exp (y * log (x)); else return - exp (y * log (x)); } else { double value; errno = EDOM; __asm ("fmove%.d %#0rnan,%0" /* quiet NaN */ : "=f" (value) : /* no inputs */); return value; } } } __inline static const double fabs (double x) { double value; __asm ("fabs%.x %1,%0" : "=f" (value) : "f" (x)); return value; } __inline static const double ceil (double x) { int rounding_mode, round_up; double value; __asm volatile ("fmove%.l fpcr,%0" : "=dm" (rounding_mode) : /* no inputs */ ); round_up = rounding_mode | 0x30; __asm volatile ("fmove%.l %0,fpcr" : /* no outputs */ : "dmi" (round_up)); __asm volatile ("fint%.x %1,%0" : "=f" (value) : "f" (x)); __asm volatile ("fmove%.l %0,fpcr" : /* no outputs */ : "dmi" (rounding_mode)); return value; } __inline static const double floor (double x) { int rounding_mode, round_down; double value; __asm volatile ("fmove%.l fpcr,%0" : "=dm" (rounding_mode) : /* no inputs */ ); round_down = (rounding_mode & ~0x10) | 0x20; __asm volatile ("fmove%.l %0,fpcr" : /* no outputs */ : "dmi" (round_down)); __asm volatile ("fint%.x %1,%0" : "=f" (value) : "f" (x)); __asm volatile ("fmove%.l %0,fpcr" : /* no outputs */ : "dmi" (rounding_mode)); return value; } __inline static const double rint (double x) { int rounding_mode, round_nearest; double value; __asm volatile ("fmove%.l fpcr,%0" : "=dm" (rounding_mode) : /* no inputs */ ); round_nearest = rounding_mode & ~0x30; __asm volatile ("fmove%.l %0,fpcr" : /* no outputs */ : "dmi" (round_nearest)); __asm volatile ("fint%.x %1,%0" : "=f" (value) : "f" (x)); __asm volatile ("fmove%.l %0,fpcr" : /* no outputs */ : "dmi" (rounding_mode)); return value; } __inline static const double fmod (double x, double y) { double value; __asm ("fmod%.x %2,%0" : "=f" (value) : "0" (x), "f" (y)); return value; } __inline static const double drem (double x, double y) { double value; __asm ("frem%.x %2,%0" : "=f" (value) : "0" (x), "f" (y)); return value; } __inline static const double scalb (double x, int n) { double value; __asm ("fscale%.l %2,%0" : "=f" (value) : "0" (x), "dmi" (n)); return value; } __inline static double logb (double x) { double exponent; __asm ("fgetexp%.x %1,%0" : "=f" (exponent) : "f" (x)); return exponent; } __inline static const double ldexp (double x, int n) { double value; __asm ("fscale%.l %2,%0" : "=f" (value) : "0" (x), "dmi" (n)); return value; } __inline static double frexp (double x, int *exp) { double float_exponent; int int_exponent; double mantissa; __asm ("fgetexp%.x %1,%0" : "=f" (float_exponent) /* integer-valued float */ : "f" (x)); int_exponent = (int) float_exponent; __asm ("fgetman%.x %1,%0" : "=f" (mantissa) /* 1.0 <= mantissa < 2.0 */ : "f" (x)); if (mantissa != 0) { __asm ("fscale%.b %#-1,%0" : "=f" (mantissa) /* mantissa /= 2.0 */ : "0" (mantissa)); int_exponent += 1; } *exp = int_exponent; return mantissa; } __inline static double modf (double x, double *ip) { double temp; __asm ("fintrz%.x %1,%0" : "=f" (temp) /* integer-valued float */ : "f" (x)); *ip = temp; return x - temp; } 0707070000020014071004440000020000020000010556570460565027500002400000030545g++-include/Fix16.h// This may look like C code, but it is really -*- C++ -*- /* Copyright (C) 1988 Free Software Foundation written by Kurt Baudendistel (gt-eedsp!baud@gatech.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 _Fix16_h #pragma once #define _Fix16_h 1 #include #include // constant definitions #define Fix16_fs ((double)((unsigned)(1 << 15))) #define Fix16_msb (1 << 15) #define Fix16_m_max ((1 << 15) - 1) #define Fix16_m_min ((short)(1 << 15)) #define Fix16_mult Fix16_fs #define Fix16_div (1./Fix16_fs) #define Fix16_max (1. - .5/Fix16_fs) #define Fix16_min (-1.) #define Fix32_fs ((double)((unsigned long)(1 << 31))) #define Fix32_msb ((unsigned long)(1 << 31)) #define Fix32_m_max ((1 << 31) - 1) #define Fix32_m_min ((long)(1 << 31)) #define Fix32_mult Fix32_fs #define Fix32_div (1./Fix32_fs) #define Fix32_max (1. - .5/Fix32_fs) #define Fix32_min (-1.) // // Fix16 class: 16-bit Fixed point data type // // consists of a 16-bit mantissa (sign bit & 15 data bits). // class Fix16 { friend class Fix32; short m; short round(double d); short assign(double d); Fix16(short i); Fix16(int i); operator double(); public: Fix16(); Fix16(Fix16& f); Fix16(double d); Fix16(Fix32& f); ~Fix16(); Fix16& operator=(Fix16& f); Fix16& operator=(double d); Fix16& operator=(Fix32& f); friend short& mantissa(Fix16& f); friend double value(Fix16& f); Fix16 operator + (); Fix16 operator - (); friend Fix16 operator + (Fix16& f, Fix16& g); friend Fix16 operator - (Fix16& f, Fix16& g); friend Fix32 operator * (Fix16& f, Fix16& g); friend Fix16 operator / (Fix16& f, Fix16& g); friend Fix16 operator << (Fix16& f, int b); friend Fix16 operator >> (Fix16& f, int b); Fix16& operator += (Fix16& f); Fix16& operator -= (Fix16& f); Fix16& operator *= (Fix16& ); Fix16& operator /= (Fix16& f); Fix16& operator <<=(int b); Fix16& operator >>=(int b); friend int operator == (Fix16& f, Fix16& g); friend int operator != (Fix16& f, Fix16& g); friend int operator >= (Fix16& f, Fix16& g); friend int operator <= (Fix16& f, Fix16& g); friend int operator > (Fix16& f, Fix16& g); friend int operator < (Fix16& f, Fix16& g); friend istream& operator >> (istream& s, Fix16& f); friend ostream& operator << (ostream& s, Fix16& f); void overflow(short&); void range_error(short&); friend Fix16 operator * (Fix16& f, int g); friend Fix16 operator * (int g, Fix16& f); Fix16& operator *= (int g); }; // // Fix32 class: 32-bit Fixed point data type // // consists of a 32-bit mantissa (sign bit & 31 data bits). // class Fix32 { friend class Fix16; long m; long round(double d); long assign(double d); Fix32(long i); operator double(); public: Fix32(); Fix32(Fix32& f); Fix32(Fix16& f); Fix32(double d); ~Fix32(); Fix32& operator = (Fix32& f); Fix32& operator = (Fix16& f); Fix32& operator = (double d); friend long& mantissa(Fix32& f); friend double value(Fix32& f); Fix32 operator + (); Fix32 operator - (); friend Fix32 operator + (Fix32& f, Fix32& g); friend Fix32 operator - (Fix32& f, Fix32& g); friend Fix32 operator * (Fix32& f, Fix32& g); friend Fix32 operator / (Fix32& f, Fix32& g); friend Fix32 operator << (Fix32& f, int b); friend Fix32 operator >> (Fix32& f, int b); friend Fix32 operator * (Fix16& f, Fix16& g); Fix32& operator += (Fix32& f); Fix32& operator -= (Fix32& f); Fix32& operator *= (Fix32& f); Fix32& operator /= (Fix32& f); Fix32& operator <<=(int b); Fix32& operator >>=(int b); friend int operator == (Fix32& f, Fix32& g); friend int operator != (Fix32& f, Fix32& g); friend int operator >= (Fix32& f, Fix32& g); friend int operator <= (Fix32& f, Fix32& g); friend int operator > (Fix32& f, Fix32& g); friend int operator < (Fix32& f, Fix32& g); friend istream& operator >> (istream& s, Fix32& f); friend ostream& operator << (ostream& s, Fix32& f); void overflow(long& i); void range_error(long& i); friend Fix32 operator * (Fix32& f, int g); friend Fix32 operator * (int g, Fix32& f); Fix32& operator *= (int g); }; inline Fix16::~Fix16() {} inline short Fix16::round(double d) { return short( (d >= 0)? d + 0.5 : d - 0.5); } inline Fix16::Fix16(short i) { m = i; } inline Fix16::Fix16(int i) { m = i; } inline Fix16::operator double() { return Fix16_div * m; } inline Fix16::Fix16() { m = 0; } inline Fix16::Fix16(Fix16& f) { m = f.m; } inline Fix16::Fix16(double d) { m = assign(d); } inline Fix16& Fix16::operator=(Fix16& f) { m = f.m; return *this; } inline Fix16& Fix16::operator=(double d) { m = assign(d); return *this; } inline Fix32::Fix32() { m = 0; } inline Fix32::Fix32(long i) { m = i; } inline Fix32:: operator double() { return Fix32_div * m; } inline Fix32::Fix32(Fix32& f) { m = f.m; } inline Fix32::Fix32(Fix16& f) { m = long(f.m) << 16; } inline Fix32::Fix32(double d) { m = assign(d); } inline Fix16::Fix16(Fix32& f) { m = f.m >> 16; } inline Fix16& Fix16::operator=(Fix32& f) { m = f.m >> 16; return *this; } inline Fix32& Fix32::operator=(Fix32& f) { m = f.m; return *this; } inline Fix32& Fix32::operator=(Fix16& f) { m = long(f.m) << 16; return *this; } inline Fix32& Fix32::operator=(double d) { m = assign(d); return *this; } inline short& mantissa(Fix16& f) { return f.m; } inline double value(Fix16& f) { return double(f); } inline Fix16 Fix16::operator+() { return m; } inline Fix16 Fix16::operator-() { return -m; } inline Fix16 operator+(Fix16& f, Fix16& g) { short sum = f.m + g.m; if ( (f.m ^ sum) & (g.m ^ sum) & Fix16_msb ) f.overflow(sum); return sum; } inline Fix16 operator-(Fix16& f, Fix16& g) { short sum = f.m - g.m; if ( (f.m ^ sum) & (-g.m ^ sum) & Fix16_msb ) f.overflow(sum); return sum; } inline Fix32 operator*(Fix16& f, Fix16& g) { return Fix32( long( long(f.m) * long(g.m) << 1)); } inline Fix16 operator<<(Fix16& a, int b) { return a.m << b; } inline Fix16 operator>>(Fix16& a, int b) { return a.m >> b; } inline Fix16& Fix16:: operator+=(Fix16& f) { return *this = *this + f; } inline Fix16& Fix16:: operator-=(Fix16& f) { return *this = *this - f; } inline Fix16& Fix16::operator*=(Fix16& f) { return *this = *this * f; } inline Fix16& Fix16:: operator/=(Fix16& f) { return *this = *this / f; } inline Fix16& Fix16:: operator<<=(int b) { return *this = *this << b; } inline Fix16& Fix16:: operator>>=(int b) { return *this = *this >> b; } inline int operator==(Fix16& f, Fix16& g) { return f.m == g.m; } inline int operator!=(Fix16& f, Fix16& g) { return f.m != g.m; } inline int operator>=(Fix16& f, Fix16& g) { return f.m >= g.m; } inline int operator<=(Fix16& f, Fix16& g) { return f.m <= g.m; } inline int operator>(Fix16& f, Fix16& g) { return f.m > g.m; } inline int operator<(Fix16& f, Fix16& g) { return f.m < g.m; } inline istream& operator>>(istream& s, Fix16& f) { double d; s >> d; f = d; return s; } inline ostream& operator<<(ostream& s, Fix16& f) { return s << double(f); } inline Fix16 operator*(Fix16& f, int g) { return Fix16(short(f.m * g)); } inline Fix16 operator*(int g, Fix16& f) { return f * g; } inline Fix16& Fix16::operator*=(int g) { return *this = *this * g; } inline Fix32::~Fix32() {} inline long Fix32::round(double d) { return long( (d >= 0)? d + 0.5 : d - 0.5); } inline long& mantissa(Fix32& f) { return f.m; } inline double value(Fix32& f) { return double(f); } inline Fix32 Fix32::operator+() { return m; } inline Fix32 Fix32::operator-() { return -m; } inline Fix32 operator+(Fix32& f, Fix32& g) { long sum = f.m + g.m; if ( (f.m ^ sum) & (g.m ^ sum) & Fix32_msb ) f.overflow(sum); return sum; } inline Fix32 operator-(Fix32& f, Fix32& g) { long sum = f.m - g.m; if ( (f.m ^ sum) & (-g.m ^ sum) & Fix32_msb ) f.overflow(sum); return sum; } inline Fix32 operator<<(Fix32& a, int b) { return a.m << b; } inline Fix32 operator>>(Fix32& a, int b) { return a.m >> b; } inline Fix32& Fix32::operator+=(Fix32& f) { return *this = *this + f; } inline Fix32& Fix32::operator-=(Fix32& f) { return *this = *this - f; } inline Fix32& Fix32::operator*=(Fix32& f) { return *this = *this * f; } inline Fix32& Fix32::operator/=(Fix32& f) { return *this = *this / f; } inline Fix32& Fix32::operator<<=(int b) { return *this = *this << b; } inline Fix32& Fix32::operator>>=(int b) { return *this = *this >> b; } inline int operator==(Fix32& f, Fix32& g) { return f.m == g.m; } inline int operator!=(Fix32& f, Fix32& g) { return f.m != g.m; } inline int operator>=(Fix32& f, Fix32& g) { return f.m >= g.m; } inline int operator<=(Fix32& f, Fix32& g) { return f.m <= g.m; } inline int operator>(Fix32& f, Fix32& g) { return f.m > g.m; } inline int operator<(Fix32& f, Fix32& g) { return f.m < g.m; } inline istream& operator>>(istream& s, Fix32& f) { double d; s >> d; f = d; return s; } inline ostream& operator<<(ostream& s, Fix32& f) { return s << double(f); } inline Fix32 operator*(Fix32& f, int g) { return Fix32(long(f.m * g)); } inline Fix32 operator*(int g, Fix32& f) { return f * g; } inline Fix32& Fix32::operator*=(int g) { return *this = *this * g; } // active error handler declarations typedef void (*Fix16_peh)(short&); typedef void (*Fix32_peh)(long&); extern Fix16_peh Fix16_overflow_handler; extern Fix32_peh Fix32_overflow_handler; extern Fix16_peh Fix16_range_error_handler; extern Fix32_peh Fix32_range_error_handler; // error handler declarations extern Fix16_peh set_Fix16_overflow_handler(Fix16_peh); extern Fix32_peh set_Fix32_overflow_handler(Fix32_peh); extern void set_overflow_handler(Fix16_peh, Fix32_peh); extern Fix16_peh set_Fix16_range_error_handler(Fix16_peh); extern Fix32_peh set_Fix32_range_error_handler(Fix32_peh); extern void set_range_error_handler(Fix16_peh, Fix32_peh); extern void Fix16_ignore(short&), Fix16_overflow_saturate(short&), Fix16_overflow_warning_saturate(short&), Fix16_warning(short&), Fix16_abort(short&); extern void Fix32_ignore(long&), Fix32_overflow_saturate(long&), Fix32_overflow_warning_saturate(long&), Fix32_warning(long&), Fix32_abort(long&); #endif 0707070000020014161004440000020000020000011245430460565027700002600000000036g++-include/bstring.h#pragma once #include 0707070000020020541004440000020000020000011405300460565032700002500000000036g++-include/memory.h#pragma once #include 0707070000020020611004440000020000020000010446470460565033100002300000000072g++-include/file.h #ifndef file_h #pragma once #include #endif 0707070000020020641004440000020000020000010343250460565033300002500000000036g++-include/random.h#pragma once #include 0707070000020020671004440000020000020000011552510460565033500002500000001422g++-include/unistd.h#ifndef unistd_h #pragma once #define unistd_h 1 #include /* A safe-looking set of things from various system versions */ #ifndef SEEK_SET #define SEEK_SET 0 #endif #ifndef SEEK_CUR #define SEEK_CUR 1 #endif #ifndef SEEK_END #define SEEK_END 2 #endif #ifndef GF_PATH #define GF_PATH "/etc/group" #endif #ifndef PF_PATH #define PF_PATH "/etc/passwd" #endif #ifndef IN_PATH #define IN_PATH "/usr/include" #endif #ifndef R_OK #define R_OK 4 #endif #ifndef W_OK #define W_OK 2 #endif #ifndef X_OK #define X_OK 1 #endif #ifndef F_OK #define F_OK 0 #endif #ifndef NULL #define NULL 0 #endif #ifndef F_ULOCK #define F_ULOCK 0 #endif #ifndef F_LOCK #define F_LOCK 1 #endif #ifndef F_TLOCK #define F_TLOCK 2 #endif #ifndef F_TEST #define F_TEST 3 #endif #endif 0707070000020020731004440000020000020000011642020460565033700002200000001207g++-include/grp.h #ifndef grp_h #pragma once #include extern "C" { #define getgrent c_proto_getgrent #define getgrgid c_proto_getgrgid #define getgrnam c_proto_getgrnam #define setgrent c_proto_setgrent #define endgrent c_proto_endgrent #define fgetgrent c_proto_fgetgrent #define KERNEL #include "//usr/include/grp.h" #ifndef grp_h #define grp_h 1 #endif #undef getgrent #undef getgrgid #undef getgrnam #undef KERNEL extern struct group* getgrent(); extern struct group* fgetgrent(FILE*); extern struct group* getgrgid(int); extern struct group* getgrnam(const char*); extern void setgrent(); extern void endgrent(); } #endif 0707070000020020751004440000020000020000011065020460565034100002400000000222g++-include/errno.h#ifndef errno_h #pragma once extern "C" { #include "//usr/include/errno.h" } #ifndef errno_h #define errno_h 1 #endif #include #endif 0707070000020020771004440000020000020000010742600460565034300002300000003253g++-include/time.h#ifndef time_h #define time_h 1 // this kludge will probably work on most systems #include /* sorry, but needed for DGUX */ #include /* sorry, but needed for USG */ #include extern "C" { #define gmtime c_proto_gmtime #define localtime c_proto_localtime #define asctime c_proto_asctime #define ctime c_proto_ctime #define tzset c_proto_tzset #define tzsetwall c_proto_tzsetwall #define timezone c_proto_timezone #define getitimer c_proto_getitimer #define setitimer c_proto_setitimer #define gettimeofday c_proto_gettimeofday #define settimeofday c_proto_settimeofday #define KERNEL #ifndef USG #include "//usr/include/sys/time.h" #endif #include "//usr/include/sys/times.h" #include "//usr/include/time.h" #undef KERNEL #undef gmtime #undef localtime #undef asctime #undef ctime #undef tzset #undef tzsetwall #undef timezone #undef getitimer #undef setitimer #undef gettimeofday #undef settimeofday extern struct tm* localtime(long*); extern struct tm* gmtime(long*); extern char* ctime(long*); extern char* asctime(struct tm*); extern void tzset(); extern void tzsetwall(); extern long times(struct tms*); #if defined(USG) extern long timezone; extern int daylight; extern char* tzname[]; #else typedef struct c_proto_timezone timezone; extern char* timezone(int, int); extern int getitimer(int, struct itimerval*); extern int setitimer(int, struct itimerval*, struct itimerval*); extern int gettimeofday(struct timeval*, struct timezone*); extern int settimeofday(struct timeval*, struct timezone*); #endif } #else #ifdef ctime /* What to do if "//usr/include/sys/time.h" tries to include us. */ #include "//usr/include/time.h" #endif #endif 0707070000020021001004440000020000020000011336310460565034500002200000001165g++-include/pwd.h#ifndef pwd_h #pragma once // the Interviews-based standard kludge again extern "C" { #define getpwent c_proto_getpwent #define getpwuid c_proto_getpwuid #define getpwnam c_proto_getpwnam #define setpwent c_proto_setpwent #define endpwent c_proto_endpwent #define KERNEL #include "//usr/include/pwd.h" #ifndef pwd_h #define pwd_h 1 #endif #undef getpwent #undef getpwuid #undef getpwnam #undef setpwent #undef endpwent #undef KERNEL extern struct passwd* getpwent(); extern struct passwd* getpwuid(int); extern struct passwd* getpwnam(char*); extern int setpwent(); extern int endpwent(); } #endif 0707070000020021141004440000020000020000010757260460565034700002700000006727g++-include/RAVLMap.hP// 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 #pragma once #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(); }; inline RAVLNode::RAVLNode( h, c, RAVLNode* l=0, RAVLNode* r=0, int k=1) :item(h), cont(c), lt(l), rt(r), rank(k) { stat = 0; } inline RAVLNode::~RAVLNode() {} 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(); }; 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 0707070000020021151004440000020000020000011354020460565035100003000000034025g++-include/RAVLMap.ccP// 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. */ #include #include #include "..RAVLMap.h" /* constants & inlines for maintaining balance & thread status in tree nodes */ #define AVLBALANCEMASK 3 #define AVLBALANCED 0 #define AVLLEFTHEAVY 1 #define AVLRIGHTHEAVY 2 #define LTHREADBIT 4 #define RTHREADBIT 8 static inline int bf(RAVLNode* t) { return t->stat & AVLBALANCEMASK; } static inline void set_bf(RAVLNode* t, int b) { t->stat = (t->stat & ~AVLBALANCEMASK) | (b & AVLBALANCEMASK); } static inline int rthread(RAVLNode* t) { return t->stat & RTHREADBIT; } static inline void set_rthread(RAVLNode* t, int b) { if (b) t->stat |= RTHREADBIT; else t->stat &= ~RTHREADBIT; } static inline int lthread(RAVLNode* t) { return t->stat & LTHREADBIT; } static inline void set_lthread(RAVLNode* t, int b) { if (b) t->stat |= LTHREADBIT; else t->stat &= ~LTHREADBIT; } /* traversal primitives */ RAVLNode* RAVLMap::leftmost() { RAVLNode* t = root; if (t != 0) while (t->lt != 0) t = t->lt; return t; } RAVLNode* RAVLMap::rightmost() { RAVLNode* t = root; if (t != 0) while (t->rt != 0) t = t->rt; return t; } RAVLNode* RAVLMap::succ(RAVLNode* t) { RAVLNode* r = t->rt; if (!rthread(t)) while (!lthread(r)) r = r->lt; return r; } RAVLNode* RAVLMap::pred(RAVLNode* t) { RAVLNode* l = t->lt; if (!lthread(t)) while (!rthread(l)) l = l->rt; return l; } Pix RAVLMap::seek( key) { RAVLNode* t = root; if (t == 0) return 0; for (;;) { int cmp = CMP(key, t->item); if (cmp == 0) return Pix(t); else if (cmp < 0) { if (lthread(t)) return 0; else t = t->lt; } else if (rthread(t)) return 0; else t = t->rt; } } int RAVLMap::rankof( key) { int r; RAVLNode* t = root; if (t == 0) return 0; for (r=t->rank; t != 0; r+=t->rank) { int cmp = CMP(key, t->item); if (cmp == 0) return r; else if (cmp < 0) { if (lthread(t)) return 0; else { r -= t->rank; t = t->lt; } } else if (rthread(t)) return 0; else { t = t->rt; } } return 0; } Pix RAVLMap::ranktoPix(int i) { int r; RAVLNode* t = root; if ((i<1)||(i>count)) return 0; for (r=t->rank; r!=i; r+=t->rank) { if (r>i) { r -= t->rank; t = t->lt; } else t = t->rt; } return Pix(t); } /* The combination of threads and AVL bits make adding & deleting interesting, but very awkward. We use the following statics to avoid passing them around recursively */ static int _need_rebalancing; // to send back balance info from rec. calls static * _target_item; // add/del_item target static RAVLNode* _found_node; // returned added/deleted node static int _already_found; // for deletion subcases static int _rank_changed; // for rank computation void RAVLMap:: _add(RAVLNode*& t) { int cmp = CMP(*_target_item, t->item); if (cmp == 0) { _found_node = t; return; } else if (cmp < 0) { if (lthread(t)) { ++count; _found_node = new RAVLNode(*_target_item, def); set_lthread(_found_node, 1); set_rthread(_found_node, 1); _found_node->lt = t->lt; _found_node->rt = t; t->lt = _found_node; set_lthread(t, 0); _need_rebalancing = 1; _rank_changed = 1; } else _add(t->lt); if (_rank_changed) ++t->rank; if (_need_rebalancing) { switch(bf(t)) { case AVLRIGHTHEAVY: set_bf(t, AVLBALANCED); _need_rebalancing = 0; return; case AVLBALANCED: set_bf(t, AVLLEFTHEAVY); return; case AVLLEFTHEAVY: RAVLNode* l = t->lt; if (bf(l) == AVLLEFTHEAVY) { t->rank -= l->rank; if (rthread(l)) t->lt = l; else t->lt = l->rt; set_lthread(t, rthread(l)); l->rt = t; set_rthread(l, 0); set_bf(t, AVLBALANCED); set_bf(l, AVLBALANCED); t = l; _need_rebalancing = 0; } else { RAVLNode* r = l->rt; r->rank += l->rank; t->rank -= r->rank; set_rthread(l, lthread(r)); if (lthread(r)) l->rt = r; else l->rt = r->lt; r->lt = l; set_lthread(r, 0); set_lthread(t, rthread(r)); if (rthread(r)) t->lt = r; else t->lt = r->rt; r->rt = t; set_rthread(r, 0); if (bf(r) == AVLLEFTHEAVY) set_bf(t, AVLRIGHTHEAVY); else set_bf(t, AVLBALANCED); if (bf(r) == AVLRIGHTHEAVY) set_bf(l, AVLLEFTHEAVY); else set_bf(l, AVLBALANCED); set_bf(r, AVLBALANCED); t = r; _need_rebalancing = 0; return; } } } } else { if (rthread(t)) { ++count; _found_node = new RAVLNode(*_target_item, def); set_rthread(t, 0); set_lthread(_found_node, 1); set_rthread(_found_node, 1); _found_node->lt = t; _found_node->rt = t->rt; t->rt = _found_node; _need_rebalancing = 1; _rank_changed = 1; } else _add(t->rt); if (_need_rebalancing) { switch(bf(t)) { case AVLLEFTHEAVY: set_bf(t, AVLBALANCED); _need_rebalancing = 0; return; case AVLBALANCED: set_bf(t, AVLRIGHTHEAVY); return; case AVLRIGHTHEAVY: RAVLNode* r = t->rt; if (bf(r) == AVLRIGHTHEAVY) { r->rank += t->rank; if (lthread(r)) t->rt = r; else t->rt = r->lt; set_rthread(t, lthread(r)); r->lt = t; set_lthread(r, 0); set_bf(t, AVLBALANCED); set_bf(r, AVLBALANCED); t = r; _need_rebalancing = 0; } else { RAVLNode* l = r->lt; r->rank -= l->rank; l->rank += t->rank; set_lthread(r, rthread(l)); if (rthread(l)) r->lt = l; else r->lt = l->rt; l->rt = r; set_rthread(l, 0); set_rthread(t, lthread(l)); if (lthread(l)) t->rt = l; else t->rt = l->lt; l->lt = t; set_lthread(l, 0); if (bf(l) == AVLRIGHTHEAVY) set_bf(t, AVLLEFTHEAVY); else set_bf(t, AVLBALANCED); if (bf(l) == AVLLEFTHEAVY) set_bf(r, AVLRIGHTHEAVY); else set_bf(r, AVLBALANCED); set_bf(l, AVLBALANCED); t = l; _need_rebalancing = 0; return; } } } } } & RAVLMap::operator [] ( item) { if (root == 0) { ++count; root = new RAVLNode(item, def); set_rthread(root, 1); set_lthread(root, 1); return root->cont; } else { _target_item = &item; _need_rebalancing = 0; _rank_changed = 0; _add(root); return _found_node->cont; } } void RAVLMap::_del(RAVLNode* par, RAVLNode*& t) { int comp; if (_already_found) { if (rthread(t)) comp = 0; else comp = 1; } else comp = CMP(*_target_item, t->item); if (comp == 0) { if (lthread(t) && rthread(t)) { _found_node = t; if (t == par->lt) { set_lthread(par, 1); par->lt = t->lt; } else { set_rthread(par, 1); par->rt = t->rt; } _need_rebalancing = 1; _rank_changed = 1; return; } else if (lthread(t)) { _found_node = t; RAVLNode* s = succ(t); if (s != 0 && lthread(s)) s->lt = t->lt; t = t->rt; _need_rebalancing = 1; _rank_changed = 1; return; } else if (rthread(t)) { _found_node = t; RAVLNode* p = pred(t); if (p != 0 && rthread(p)) p->rt = t->rt; t = t->lt; _need_rebalancing = 1; _rank_changed = 1; return; } else // replace item & find someone deletable { RAVLNode* p = pred(t); t->item = p->item; t->cont = p->cont; _already_found = 1; comp = -1; // fall through below to left } } if (comp < 0) { if (lthread(t)) return; _del(t, t->lt); if (_rank_changed) --t->rank; if (!_need_rebalancing) return; switch (bf(t)) { case AVLLEFTHEAVY: set_bf(t, AVLBALANCED); return; case AVLBALANCED: set_bf(t, AVLRIGHTHEAVY); _need_rebalancing = 0; return; case AVLRIGHTHEAVY: RAVLNode* r = t->rt; switch (bf(r)) { case AVLBALANCED: r->rank += t->rank; if (lthread(r)) t->rt = r; else t->rt = r->lt; set_rthread(t, lthread(r)); r->lt = t; set_lthread(r, 0); set_bf(t, AVLRIGHTHEAVY); set_bf(r, AVLLEFTHEAVY); _need_rebalancing = 0; t = r; return; case AVLRIGHTHEAVY: r->rank += t->rank; if (lthread(r)) t->rt = r; else t->rt = r->lt; set_rthread(t, lthread(r)); r->lt = t; set_lthread(r, 0); set_bf(t, AVLBALANCED); set_bf(r, AVLBALANCED); t = r; return; case AVLLEFTHEAVY: RAVLNode* l = r->lt; r->rank -= l->rank; l->rank += t->rank; set_lthread(r, rthread(l)); if (rthread(l)) r->lt = l; else r->lt = l->rt; l->rt = r; set_rthread(l, 0); set_rthread(t, lthread(l)); if (lthread(l)) t->rt = l; else t->rt = l->lt; l->lt = t; set_lthread(l, 0); if (bf(l) == AVLRIGHTHEAVY) set_bf(t, AVLLEFTHEAVY); else set_bf(t, AVLBALANCED); if (bf(l) == AVLLEFTHEAVY) set_bf(r, AVLRIGHTHEAVY); else set_bf(r, AVLBALANCED); set_bf(l, AVLBALANCED); t = l; return; } } } else { if (rthread(t)) return; _del(t, t->rt); if (!_need_rebalancing) return; switch (bf(t)) { case AVLRIGHTHEAVY: set_bf(t, AVLBALANCED); return; case AVLBALANCED: set_bf(t, AVLLEFTHEAVY); _need_rebalancing = 0; return; case AVLLEFTHEAVY: RAVLNode* l = t->lt; switch (bf(l)) { case AVLBALANCED: t->rank -= l->rank; if (rthread(l)) t->lt = l; else t->lt = l->rt; set_lthread(t, rthread(l)); l->rt = t; set_rthread(l, 0); set_bf(t, AVLLEFTHEAVY); set_bf(l, AVLRIGHTHEAVY); _need_rebalancing = 0; t = l; return; case AVLLEFTHEAVY: t->rank -= l->rank; if (rthread(l)) t->lt = l; else t->lt = l->rt; set_lthread(t, rthread(l)); l->rt = t; set_rthread(l, 0); set_bf(t, AVLBALANCED); set_bf(l, AVLBALANCED); t = l; return; case AVLRIGHTHEAVY: RAVLNode* r = l->rt; r->rank += l->rank; t->rank -= r->rank; set_rthread(l, lthread(r)); if (lthread(r)) l->rt = r; else l->rt = r->lt; r->lt = l; set_lthread(r, 0); set_lthread(t, rthread(r)); if (rthread(r)) t->lt = r; else t->lt = r->rt; r->rt = t; set_rthread(r, 0); if (bf(r) == AVLLEFTHEAVY) set_bf(t, AVLRIGHTHEAVY); else set_bf(t, AVLBALANCED); if (bf(r) == AVLRIGHTHEAVY) set_bf(l, AVLLEFTHEAVY); else set_bf(l, AVLBALANCED); set_bf(r, AVLBALANCED); t = r; return; } } } } void RAVLMap::del( item) { if (root == 0) return; _need_rebalancing = 0; _already_found = 0; _found_node = 0; _rank_changed = 0; _target_item = &item; _del(root, root); if (_found_node) { delete(_found_node); if (--count == 0) root = 0; } } void RAVLMap::_kill(RAVLNode* t) { if (t != 0) { if (!lthread(t)) _kill(t->lt); if (!rthread(t)) _kill(t->rt); delete t; } } RAVLMap::RAVLMap(RAVLMap& b) :(b.def) { root = 0; count = 0; for (Pix i = b.first(); i != 0; b.next(i)) (*this)[b.key(i)] = b.contents(i); } int RAVLMap::OK() { int v = 1; if (root == 0) v = count == 0; else { int n = 1; RAVLNode* trail = leftmost(); v &= rankof(trail->item) == n; RAVLNode* t = succ(trail); while (t != 0) { ++n; v &= CMP(trail->item, t->item) < 0; v &= rankof(t->item) == n; trail = t; t = succ(t); } v &= n == count; } if (!v) error("invariant failure"); return v; } 0707070000020021161004440000020000020000011232150460565035300003000000003254g++-include/AllocRing.h// This may look like C code, but it is really -*- C++ -*- /* Copyright (C) 1989 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 _AllocRing_h #pragma once #define _AllocRing_h 1 /* An AllocRing holds the last n malloc'ed strings, reallocating/reusing one only when the queue wraps around. It thus guarantees that the last n allocations are intact. It is useful for things like I/O formatting where reasonable restrictions may be made about the number of allowable live allocations before auto-deletion. */ class AllocRing { struct AllocQNode { void* ptr; int sz; }; AllocQNode* nodes; int n; int current; int find(void* p); public: AllocRing(int max); ~AllocRing(); void* alloc(int size); int contains(void* ptr); void clear(); void free(void* p); }; #endif 0707070000020021171004440000020000020000010621130460565035600002500000011232g++-include/GetOpt.h/* Getopt for GNU. Copyright (C) 1987, 1989 Free Software Foundation, Inc. (Modified by Douglas C. Schmidt for use with GNU G++.) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of `argv' so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable _POSIX_OPTION_ORDER disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #ifndef GetOpt_h #pragma once #define GetOpt_h 1 #include #include class GetOpt { private: /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Describe how to deal with options that follow non-option ARGV-elements. UNSPECIFIED means the caller did not specify anything; the default is then REQUIRE_ORDER if the environment variable _OPTIONS_FIRST is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options. Stop option processing when the first non-option is seen. This is what Unix does. PERMUTE is the default. We permute the contents of `argv' as we scan, so that eventually all the options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code zero. Using `-' as the first character of the list of option characters requests this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return EOF with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; void exchange (char **argv); public: /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns EOF, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ int optind; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr; int nargc; char **nargv; char *noptstring; GetOpt (int argc, char **argv, char *optstring); int operator () (void); }; #endif 0707070000020021201004440000020000020000010657300460565036000002500000000021g++-include/stdlib.h#include 0707070000020021311004440000020000020000011562530460565036200003200000000727g++-include/getpagesize.h#if defined(BSD) || defined(DGUX) #ifndef BSD4_1 #define HAVE_GETPAGESIZE #endif #endif #ifndef HAVE_GETPAGESIZE #include #ifdef EXEC_PAGESIZE #define getpagesize() EXEC_PAGESIZE #else #ifdef NBPG #define getpagesize() NBPG * CLSIZE #ifndef CLSIZE #define CLSIZE 1 #endif /* no CLSIZE */ #else /* no NBPG */ #ifdef NBPC #define getpagesize() NBPC #endif /* NBPC */ #endif /* no NBPG */ #endif /* no EXEC_PAGESIZE */ #endif /* not HAVE_GETPAGESIZE */ 0707070000020021341004440000020000020000011357500460565036400002500000000021g++-include/malloc.h#include 0707070000020021401004440000020000020000011173640460565036600002400000000263g++-include/fcntl.h#ifndef fcntl_h #pragma once extern "C" { #define KERNEL #include "//usr/include/fcntl.h" #ifndef fcntl_h #define fcntl_h 1 #endif #undef KERNEL } #include #endif 0707070000020021421004440000020000020000010627520460565037000003300000007312g++-include/RandomInteger.// This may look like C code, but it is really -*- C++ -*- /* Copyright (C) 1990 Free Software Foundation adapted from a submission from John Reidl 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 _RandomInteger_h #pragma once #define _RandomInteger_h 1 // RandomInteger uses a random number generator to generate an integer // in a specified range. By default the range is 0..1. Since in my // experience random numbers are often needed for a wide variety of // ranges in the same program, this generator accepts a new low or high value // as an argument to the asLong and operator() methods to temporarily // override stored values #include #include "RNG.h" class RandomInteger { protected: RNG *pGenerator; long pLow; long pHigh; long _asLong(long, long); public: RandomInteger(long low, long high, RNG *gen); RandomInteger(long high, RNG *gen); RandomInteger(RNG *gen); // read params long low() const; long high() const; RNG* generator() const; // change params long low(long x); long high(long x); RNG* generator(RNG *gen); // get a random number long asLong(); long operator()(); // synonym for asLong int asInt(); // (possibly) truncate as int // override params for one shot long asLong(long high); long asLong(long low, long high); long operator () (long high); // synonyms long operator () (long low, long high); }; inline RandomInteger::RandomInteger(long low, long high, RNG *gen) : pLow((low < high) ? low : high), pHigh((low < high) ? high : low), pGenerator(gen) {} inline RandomInteger::RandomInteger(long high, RNG *gen) : pLow((0 < high) ? 0 : high), pHigh((0 < high) ? high : 0), pGenerator(gen) {} inline RandomInteger::RandomInteger(RNG *gen) : pLow(0), pHigh(1), pGenerator(gen) {} inline RNG* RandomInteger::generator() const { return pGenerator;} inline long RandomInteger::low() const { return pLow; } inline long RandomInteger::high() const { return pHigh; } inline RNG* RandomInteger::generator(RNG *gen) { RNG *tmp = pGenerator; pGenerator = gen; return tmp; } inline long RandomInteger::low(long x) { long tmp = pLow; pLow = x; return tmp; } inline long RandomInteger:: high(long x) { long tmp = pHigh; pHigh = x; return tmp; } inline long RandomInteger:: _asLong(long low, long high) { return (pGenerator->asLong() % (high-low+1)) + low; } inline long RandomInteger:: asLong() { return _asLong(pLow, pHigh); } inline long RandomInteger:: asLong(long high) { return _asLong(pLow, high); } inline long RandomInteger:: asLong(long low, long high) { return _asLong(low, high); } inline long RandomInteger:: operator () () { return _asLong(pLow, pHigh); } inline long RandomInteger:: operator () (long high) { return _asLong(pLow, high); } inline long RandomInteger:: operator () (long low, long high) { return _asLong(low, high); } inline int RandomInteger:: asInt() { return int(asLong()); } #endif 0707070000020021461004440000020000020000011537370460565037200002600000012600g++-include/ostream.h// This may look like C code, but it is really -*- C++ -*- /* Copyright (C) 1989 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. */ /* *** Version 1.2 -- nearly 100% AT&T 1.2 compatible *** */ /* ostream.h now separately includable */ #ifndef _ostream_h #pragma once #define _ostream_h 1 /* uncomment the next line to disable ostream << char */ //#define NO_OUTPUT_CHAR #include #include class istream; class ostream { friend class istream; protected: streambuf* bp; state_value state; // _good/_eof/_fail/_bad char ownbuf; // true if we own *bp public: ostream(const char* filename, io_mode m, access_mode a); ostream(const char* filename, const char* m); ostream(int filedesc, io_mode m); ostream(FILE* fileptr); ostream(int sz, char* buf); ostream(int filedesc, char* buf, int buflen); ostream(int filedesc); ostream(streambuf* s); ~ostream(); ostream& open(const char* filename, io_mode m, access_mode a); ostream& open(const char* filename, const char* m); ostream& open(int filedesc, io_mode m); ostream& open(FILE* fileptr); ostream& open(const char* filenam, open_mode m); ostream& close(); ostream& flush(); // stream status int rdstate(); int eof(); int fail(); int bad(); int good(); // other status queries int readable(); int writable(); int is_open(); operator void*(); int operator !(); const char* name(); char* bufptr(); // error handling void error(); void clear(state_value f = _good); // poorly named void set(state_value f); // set corresponding bit void unset(state_value); // clear corresponding bit ostream& failif(int cond); // unformatted IO ostream& put(char c); ostream& put(const char* s); ostream& put(const char* s, int slen); // formatted IO ostream& form(const char* fmt, ...); ostream& operator << (short n); ostream& operator << (unsigned short n); ostream& operator << (int n); ostream& operator << (unsigned int n); ostream& operator << (long n); ostream& operator << (unsigned long n); #ifdef __GNUG__ ostream& operator << (long long n); ostream& operator << (unsigned long long n); #endif __GNUG__ ostream& operator << (float n); ostream& operator << (double n); ostream& operator << (const char* s); #ifndef NO_OUTPUT_CHAR ostream& operator << (char c); #endif }; extern ostream cout; // stdout extern ostream cerr; // stderr inline void ostream::clear(state_value flag) { state = flag; } inline void ostream::set(state_value flag) { state = state_value(int(state) | int(flag)); } inline void ostream::unset(state_value flag) { state = state_value(int(state) & ~int(flag)); } inline int ostream::rdstate() { return int(state); } inline int ostream::good() { return state == _good; } inline int ostream::eof() { return int(state) & int(_eof); } inline int ostream::fail() { return int(state) & int(_fail); } inline int ostream::bad() { return int(state) & int(_bad); } inline ostream::operator void*() { return (state == _good)? this : 0; } inline int ostream::operator !() { return (state != _good); } inline ostream& ostream::failif(int cond) { if (cond) set(_fail); return *this; } inline int ostream::is_open() { return bp->is_open(); } inline int ostream::readable() { return 0; } inline int ostream::writable() { return (bp != 0) && (state == _good); } inline char* ostream::bufptr() { return bp->base; } inline ostream& ostream::flush() { bp->overflow(); return *this; } inline ostream& ostream::close() { bp->overflow(); bp->close(); return *this; } inline ostream& ostream::put(char ch) { return failif((state != _good) || bp->sputc(ch) == EOF); } #ifndef NO_OUTPUT_CHAR inline ostream& ostream::operator << (char ch) { return failif((state != _good) || bp->sputc(ch) == EOF); } #endif inline ostream& ostream::put(const char* s) { return failif((state != _good) || bp->sputs(s) == EOF); } inline ostream& ostream::put(const char* s, int len) { return failif((state != _good) || bp->sputsn(s, len) == EOF); } inline ostream& ostream::operator << (const char* s) { return failif((state != _good) || bp->sputs(s) == EOF); } #endif 0707070000020021521004440000020000020000010663570460565037400002600000013350g++-include/istream.h// This may look like C code, but it is really -*- C++ -*- /* Copyright (C) 1989 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. */ /* *** Version 1.2 -- nearly 100% AT&T 1.2 compatible *** */ /* istream.h now separately includable */ #ifndef _istream_h #pragma once #define _istream_h 1 #include #include class whitespace // a class used only to input and { // discard white space characters char filler; }; class ostream; class istream { friend void eatwhite(istream& s); protected: streambuf* bp; state_value state; // _good/_eof/_fail/_bad ostream* tied_to; char skipws; char ownbuf; void _flush(); char* readline (int chunk_number, char terminator); public: istream(const char* filename, io_mode m, access_mode a, int sk=1, ostream* t = 0); istream(const char* filename, const char* m, int sk=1, ostream* t = 0); istream(int filedesc, io_mode m, int sk=1, ostream* t = 0); istream(FILE* fileptr, int sk=1, ostream* t = 0); istream(int sz, char* buf, int sk=1, ostream* t = 0); istream(int filedesc, int sk=1, ostream* t = 0); istream(int filedesc, char* buf, int buflen, int sk=1, ostream* t = 0); istream(streambuf* s, int sk=1, ostream* t = 0); ~istream(); istream& open(const char* filename, io_mode m, access_mode a); istream& open(const char* filename, const char* m); istream& open(int filedesc, io_mode m); istream& open(FILE* fileptr); istream& open(const char* filenam, open_mode m); istream& close(); ostream* tie(ostream* s); int skip(int); // stream status int rdstate(); int eof(); int fail(); int bad(); int good(); // other status queries int readable(); int writable(); int is_open(); operator void*(); int operator !(); const char* name(); char* bufptr(); // error handling void error(); void clear(state_value f = _good); // poorly named void set(state_value f); // set corresponding bit void unset(state_value f); // clear corresponding bit istream& failif(int cond); // unformatted IO istream& get(char& c); istream& unget(char c); istream& putback(char c); // a synonym for unget istream& get (char* s, int n, char terminator = '\n'); istream& getline(char* s, int n, char terminator = '\n'); istream& gets (char **s, char terminator = '\n'); istream& operator >> (char& c); istream& operator >> (short& n); istream& operator >> (unsigned short& n); istream& operator >> (int& n); istream& operator >> (unsigned int& n); istream& operator >> (long& n); istream& operator >> (unsigned long& n); #ifdef __GNUG__ istream& operator >> (long long& n); istream& operator >> (unsigned long long& n); #endif istream& operator >> (float& n); istream& operator >> (double& n); istream& operator >> (char* s); istream& operator >> (whitespace& w); }; // pre-declared streams extern istream cin; // stdin extern whitespace WS; // for convenience inline void istream::clear(state_value flag) { state = flag; } inline void istream::set(state_value flag) { state = state_value(int(state) | int(flag)); } inline void istream::unset(state_value flag) { state = state_value(int(state) & ~int(flag)); } inline int istream::rdstate() { return int(state); } inline int istream::good() { return state == _good; } inline int istream::eof() { return int(state) & int(_eof); } inline int istream::fail() { return int(state) & int(_fail); } inline int istream::bad() { return int(state) & int(_bad); } inline istream::operator void*() { return (state == _good)? this : 0; } inline int istream::operator !() { return (state != _good); } inline istream& istream::failif(int cond) { if (cond) set(_fail); return *this; } inline int istream::is_open() { return bp->is_open(); } inline int istream::readable() { return (bp != 0) && (bp->is_open()) && (state == _good); } inline int istream::writable() { return 0; } inline char* istream::bufptr() { return bp->base; } inline istream& istream::close() { bp->close(); return *this; } inline int istream::skip(int sk) { int was = skipws; skipws = sk; return was; } inline istream& istream::unget(char c) { if (bp->sputback(c) == EOF) set(_fail); return *this; } inline istream& istream::putback(char c) { if (bp->sputback(c) == EOF) set(_fail); return *this; } inline void eatwhite(istream& s) { s >> WS; } #endif 0707070000020021521004440000020000020000010663570460565037400001300000000000TRAILER!!!; #ifdef __GNUG__ istream& operator >> (long long& n); istream& operator >> (unsigned long long& n); #endif istream& operator >> (float& n); istream& operator >> (double& n); istream& operator >> (char* s); istream& operator >> (whitespace& w); }; // pre-declared streams extern istream cin; // stdin extern whitespace WS; // for convenience inline void istream::clear(state_value flag) { state = flag; } inline void istream::set(state_value flag) { state = state_value(int(state) | int(flag)); } inline void istream::unset(state_value flag) { state = state_value(int(state) & ~int(flag)); } inline int istream::rdstate() { return int(state); } inline int istream::good() { return state == _good; } inline int istream::eof() { return int(state) & int(_eof); } inline int istream::fail() { return int(state) & int(_fail); } inline int istream::bad() { return int(state) & int(_bad); } inline istream::operator void*() { return (state == _good)? this : 0; } inline int istream::operator !() { return (state != _good); } inline istream& istream::failif(int cond) { if (cond) set(_fail); return *this; } inline int istream::is_open() { return bp->is_open(); } inline int istream::readable() { return (bp != 0) && (bp->is_open()) && (state == _good); } inline int istream::writable() { return 0; } inline char* istream::bufptr() { return bp->base; } inline istream& istream::close() { bp->close(); return *this; } inline int istream::skip(int sk) { int was = skipws; skipws = sk; return was; } inline istream& istream::unget(char c) { if (bp->sputback(c) == EOF) set(_fail); return *this; } inline istream& istream::putback(char c) { if (bp->sputback(c) == EOF) set(_fail); return *this; } inline void eatwhite(istream& s) { s >> WS; } #endif 0707070000020021521004440000020000020000010663570460565037400001300000000000TRAILER!!!; #ifdef __GNUG__ istream& operator >> (long long& n); istream& operator >> (unsigned long long& n); #endif istream& operator >> (float& n); istream& operator >> (double& n); istream& operator >> (char* s); istream& operator >> (whitespace& w); }; // pre-declared streams extern istream cin; // stdin extern whitespace WS; // for convenience inline void istream::clear(state_value flag) { state = flag; } inline void istream::set(state_value flag) { state = state_value(int(state) | int(flag)); } inline void istream::unset(state_value flag) { state = state_value(int(state) & ~int(flag)); } inline int istream::rdstate() { return int(state); } inline int istream::good() { return state == _good; } inline int istream::eof() { return int(state) & int(_eof); } inline int istream::fail() { return int(state) & int(_fail); } inline int istream::bad() { return int(state) & int(_bad); } inline istream::operator void*() { return (state == _good)? this : 0; } inline int istream::operator !() { return (state != _good); } inline istream& istream::failif(int cond) { if (cond) set(_fail);0707070044320245331006440003320000620000010000000460601602200001100000663534libg++.a! / 639044566 0 0 0 19106 ` JJJJJJJOOOOOOUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdUdp(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(p(\\\\\\\\\""""""""""""""""""ȮȮȮȮȮȮȮȮȮȮȮȮȮȮȮȮȮȮȮȮȮȮȮȮȮȮȮȮxxxxxxllllllllllNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNTTTTTTTTTTTTTTTTTTTTFFFFO2O2O2T.T.T.YnYnYn^^^ccchhhn*n*n*tttypypyp~R~R~Rrrrrr       (*8&8&8&8&;=???B,B,B,B,B,B,B,B,B,B,KM&M&M&OOOR"R"UWvYY]]]]]]]]]]]]__9AllocRingifind__9AllocRingPvclear__9AllocRingfree__9AllocRingPv_Z_AllocRingcontains__9AllocRingPvalloc__9AllocRingi__7Obstackii_free__7ObstackPvnewchunk__7Obstackifinish__7Obstackcontains__7ObstackPvOK__7Obstackverbose_File_error_handler__FPCcquiet_File_error_handler__FPCcfatal_File_error_handler__FPCcFile_error_handlerset_File_error_handler__FPFPCc_vinitialize__4Filereinitialize__4FilePCcsetname__4FilePCccheck_state__4Fileerror__4Fileopen__4FilePCc7io_mode11access_modeclose__4Fileopen__4FilePCcT1open__4FileP6_iobufopen__4Filei7io_moderemove__4File__4File__4FilePCc7io_mode11access_mode__4FilePCcT1__4Filei7io_mode__4FileP6_iobuf__4FileiPc7io_mode_Z_Filesetbuf__4Fileisetbuf__4FileiPcput__4FilePCcget__4FilePcicgetline__4FilePcicreadline__4Fileicgets__4FilePPccscan__4FilePCceform__4FilePCce__7ostreamP9streambuf__7ostreamiPc__7ostreamPCc7io_mode11access_mode__7ostreamPCcT1__7ostreami7io_mode__7ostreamP6_iobuf__7ostreami__7ostreamiPci_Z_ostreamopen__7ostreamPCc7io_mode11access_modeopen__7ostreamPCcT1open__7ostreami7io_modeopen__7ostreamP6_iobufopen__7ostreamPCc9open_modeform__7ostreamPCceopZalshift__7ostreamsopZalshift__7ostreamUsopZalshift__7ostreamiopZalshift__7ostreamUiopZalshift__7ostreamlopZalshift__7ostreamUlopZalshift__7ostreamxopZalshift__7ostreamUxopZalshift__7ostreamfopZalshift__7ostreamdname__7ostreamerror__7ostreamcerrcout_GLOBAL_ZDZ__7ostreamP9streambuf_GLOBAL_ZIZ__7ostreamP9streambuf__7istreamP9streambufiP7ostream__7istreamiPciP7ostream_Z_istream__7istreamPCc7io_mode11access_modeiP7ostream__7istreamPCcT1iP7ostream__7istreami7io_modeiP7ostream__7istreamP6_iobufiP7ostream__7istreamiiP7ostream__7istreamiPciiP7ostreamopen__7istreamPCc7io_mode11access_modeopen__7istreamPCcT1open__7istreami7io_modeopen__7istreamP6_iobufopen__7istreamPCc9open_modeget__7istreamRcopZarshift__7istreamR10whitespaceopZarshift__7istreamRcWSget__7istreamPcicopZarshift__7istreamPcgetline__7istreamPcicreadline__7istreamicgets__7istreamPPccopZarshift__7istreamRlopZarshift__7istreamRUlopZarshift__7istreamRdopZarshift__7istreamRiopZarshift__7istreamRUiopZarshift__7istreamRsopZarshift__7istreamRUsopZarshift__7istreamRfname__7istreamerror__7istreamtie__7istreamP7ostream_flush__7istreamcin_GLOBAL_ZDZ__7istreamP9streambufiP7ostream_GLOBAL_ZIZ__7istreamP9streambufiP7ostream__9streambuf__9streambufPci_Z_streambufdoallocate__9streambufsetbuf__9streambufPciiname__9streambufoverflow__9streambufiunderflow__9streambufsputs__9streambufPCcsputsn__9streambufPCciis_open__9streambufclose__9streambuferror__9streambufopen__9streambufPCc9open_modeopen__9streambufPCc7io_mode11access_modeopen__9streambufPCcT1open__9streambufi7io_modeopen__9streambufP6_iobuf__7filebuf__7filebufi__7filebufiPciis_open__7filebufclose__7filebufopen__7filebufPCc9open_modeunderflow__7filebufoverflow__7filebufi_Z_filebufinit_streambuf_ptrs__7Filebufis_open__7Filebufopen__7FilebufPCc7io_mode11access_modeopen__7FilebufPCcT1open__7Filebufi7io_modeopen__7FilebufP6_iobuf__7Filebuf__7FilebufPCc7io_mode11access_mode__7FilebufPCcT1__7Filebufi7io_mode__7FilebufP6_iobufclose__7Filebuf_Z_Filebufunderflow__7Filebufoverflow__7Filebufiname__7Filebufsetbuf__7FilebufPciierror__7Filebuf__8PlotFile_Z_PlotFile__8PlotFilePCc7io_mode11access_mode__8PlotFilePCcT1__8PlotFilei7io_mode__8PlotFileP6_iobuftypeZPv__8PlotFileopen__8PlotFilePCc7io_mode11access_modeopen__8PlotFilePCcT1open__8PlotFilei7io_modeopen__8PlotFileP6_iobufsetbuf__8PlotFileisetbuf__8PlotFileiPccmd__8PlotFilecopZalshift__8PlotFileiopZalshift__8PlotFilePCcarc__8PlotFileiiiiiibox__8PlotFileiiiiline__8PlotFileiiiicircle__8PlotFileiiicont__8PlotFileiidot__8PlotFileiiiiPCierase__8PlotFilelabel__8PlotFilePCclinemod__8PlotFilePCcmove__8PlotFileiipoint__8PlotFileiispace__8PlotFileiiii__5SFile_Z_SFile__5SFilePCci7io_mode11access_mode__5SFilePCciT1__5SFileii7io_mode__5SFileP6_iobufire_set_syntax__Fire_compile_pattern__FPciP17re_pattern_bufferre_compile_fastmap__FP17re_pattern_bufferre_search__FP17re_pattern_bufferPciiiP12re_registersre_search_2__FP17re_pattern_bufferPciT1iiiP12re_registersire_match_2__FP17re_pattern_bufferPUciT1iiP12re_registersire_match__FP17re_pattern_bufferPciiP12re_registersre_max_failuresre_comp__FPcre_exec__FPcerror__C6StringPCc_nilStrRep_nilStringSalloc__FP6StrRepPCciiSresize__FP6StrRepiScopy__FP6StrRepT0Scat__FP6StrRepPCciT1iScat__FP6StrRepPCciT1iT1iSprepend__FP6StrRepPCcifcompare__FRC6StringT0compare__FRC6StringPCccompare__FRC6StringT0compare__FRC6StringRC9SubStringcompare__FRC9SubStringRC6Stringcompare__FRC9SubStringT0compare__FRC9SubStringPCcsearch__C6Stringiicsearch__C6StringiiPCcimatch__C6StringiiiPCciassign__9SubStringP6StrRepPCci_Z_Regexinitialize__5RegexPCciiiT1match_info__C5RegexRiT1isearch__C5RegexPCciRiimatch__C5RegexPCcii_gsub__6StringPCciT1i_gsub__6StringRC5RegexPCcidel__6Stringiidel__6StringRC5Regexidel__6StringPCcidel__6StringRC6Stringidel__6StringRC9SubStringidel__6Stringciat__6Stringiibefore__6Stringithrough__6Stringiafter__6Stringifrom__6Stringiat__6StringRC6Stringiat__6StringRC9SubStringiat__6StringRC5Regexiat__6StringPCciat__6Stringcibefore__6StringRC6Stringibefore__6StringRC9SubStringibefore__6StringRC5Regexibefore__6Stringcibefore__6StringPCcithrough__6StringRC6Stringithrough__6StringRC9SubStringithrough__6StringRC5Regexithrough__6Stringcithrough__6StringPCciafter__6StringRC6Stringiafter__6StringRC9SubStringiafter__6Stringciafter__6StringRC5Regexiafter__6StringPCcifrom__6StringRC6Stringifrom__6StringRC9SubStringifrom__6StringRC5Regexifrom__6Stringcifrom__6StringPCcisplit__FRC6StringP6StringiT0split__FRC6StringP6StringiRC5Regexjoin__FP6StringiRC6StringSreverse__FP6StrRepT0Supcase__FP6StrRepT0Sdowncase__FP6StrRepT0Scapitalize__FP6StrRepT0replicate__Fcireplicate__FRC6Stringicommon_prefix__FRC6StringT0icommon_suffix__FRC6StringT0iopZarshift__FR7istreamR6Stringreadline__FR7istreamR6StringciopZalshift__FR7ostreamRC9SubStringfreq__C6StringRC9SubStringfreq__C6StringRT0freq__C6StringPCcfreq__C6StringcOK__C6StringOK__C9SubStringOK__C5RegexRXwhiteRXintRXdoubleRXalphaRXlowercaseRXuppercaseRXalphanumRXidentifier_GLOBAL_ZDZerror__C6StringPCc_GLOBAL_ZIZerror__C6StringPCcIalloc__FP6IntRepPCUsiiiIcalloc__FP6IntRepiIresize__FP6IntRepiIcopy__FP6IntRepPC6IntRepIcopy_long__FP6IntReplIcopy_zero__FP6IntRepIcopy_one__FP6IntRepiItolong__FPC6IntRepIislong__FPC6IntRepItodouble__FPC6IntRepIisdouble__FPC6IntRepratio__FRC7IntegerT0divide__FRC7IntegerT0R7IntegerT2compare__FPC6IntRepT0ucompare__FPC6IntRepT0compare__FPC6IntReplucompare__FPC6IntRepladd__FPC6IntRepiT0iP6IntRepadd__FPC6IntRepilP6IntRepmultiply__FPC6IntRepT0P6IntRepmultiply__FPC6IntReplP6IntRepdiv__FPC6IntRepT0P6IntRepdiv__FPC6IntReplP6IntRepdivide__FRC7IntegerlR7IntegerRlmod__FPC6IntRepT0P6IntRepmod__FPC6IntReplP6IntReplshift__FPC6IntReplP6IntReplshift__FPC6IntRepT0iP6IntRepbitop__FPC6IntRepT0P6IntRepcbitop__FPC6IntReplP6IntRepccompl__FPC6IntRepP6IntRepsetbit__FR7Integerlclearbit__FR7Integerltestbit__FRC7Integerlgcd__FPC6IntRepT0lcm__FRC7IntegerT0error__C7IntegerPCclg__FPC6IntReppower__FPC6IntReplP6IntRepabs__FPC6IntRepP6IntRepnegate__FPC6IntRepP6IntRepsqrt__FRC7IntegeratoIntRep__FPCciItoa__FPC6IntRepiidec__FRC7Integerioct__FRC7Integerihex__FRC7IntegeriopZarshift__FR7istreamR7IntegerOK__C7Integererror__C8RationalPCcnormalize__8Rationaladd__FRC8RationalT0R8Rationalsub__FRC8RationalT0R8Rationalmul__FRC8RationalT0R8Rationaldiv__FRC8RationalT0R8RationalopZnegate__FRC8Rationalabs__FRC8Rationalsqr__FRC8Rationalinvert__8Rationalcompare__FRC8RationalT0__8Rationaldfloor__FRC8Rationalceil__FRC8Rationalround__FRC8Rationaltrunc__FRC8Rationalpow__FRC8RationalRC7Integerpow__FRC8RationallopZalshift__FR7ostreamRC8RationalopZarshift__FR7istreamR8RationalOK__C8Rational_GLOBAL_ZDZerror__C8RationalPCc_GLOBAL_ZIZerror__C8RationalPCcdefault_Complex_error_handler__FPCcComplex_error_handlerset_Complex_error_handler__FPFPCc_verror__C7ComplexPCcopZtrunc_div__FRC7ComplexT0opZtrunc_div__FdRC7ComplexopZtrunc_div__FRC7ComplexdopZassign_trunc_div__7ComplexRC7ComplexopZassign_trunc_div__7Complexdexp__FRC7Complexcosh__FRC7Complexsinh__FRC7Complexcos__FRC7Complexsin__FRC7Complexlog__FRC7Complexpow__FRC7ComplexT0sqrt__FRC7Complexpow__FRC7ComplexlopZalshift__FR7ostreamRC7ComplexopZarshift__FR7istreamR7Complexerror__C6BitSetPCc_nilBitSetRepBitSetalloc__FP9BitSetRepPCUsiiiBitSetresize__FP9BitSetRepiBitSetcopy__FP9BitSetRepPC9BitSetRepopZeq__FRC6BitSetT0opZle__FRC6BitSetT0opZlt__FRC6BitSetT0shorttoBitSet__FUslongtoBitSet__FUlempty__C6BitSetcount__C6BitSetiBitSetcmpl__FPC9BitSetRepP9BitSetRepBitSetop__FPC9BitSetRepT0P9BitSetRepcset__6BitSeticlear__6BitSetiinvert__6BitSetiset__6BitSetiiclear__6BitSetiiinvert__6BitSetiitest__C6BitSetiinext__C6BitSetiiprevious__C6BitSetiilast__C6BitSetiBitSettoa__FRC6BitSetcccatoBitSet__FPCccccopZalshift__FR7ostreamRC6BitSetOK__C6BitSeterror__C9BitStringPCc_nilBitStrRep_nil_BitStringBStr_alloc__FP9BitStrRepPCUsiiiBStr_resize__FP9BitStrRepiBStr_copy__FP9BitStrRepPC9BitStrRepopZeq__FRC9BitStringT0opZle__FRC9BitStringT0opZlt__FRC9BitStringT0lcompare__FRC9BitStringT0count__C9BitStringUicmpl__FPC9BitStrRepP9BitStrRepand__FPC9BitStrRepT0P9BitStrRepor__FPC9BitStrRepT0P9BitStrRepxor__FPC9BitStrRepT0P9BitStrRepdiff__FPC9BitStrRepT0P9BitStrRepcat__FPC9BitStrRepT0P9BitStrRepcat__FPC9BitStrRepUiP9BitStrReplshift__FPC9BitStrRepiP9BitStrRepset__9BitStringiassign__9BitStringiUiclear__9BitStringiclear__9BitStringset__9BitStringinvert__9BitStringiset__9BitStringiiclear__9BitStringiiinvert__9BitStringiitest__C9BitStringiinext__C9BitStringiUiprevious__C9BitStringiUisearch__C9BitStringiiPCUsiisearch__C10BitPatternPCUsiimatch__C9BitStringiiiPCUsiimatch__C10BitPatternPCUsiiiopZassign_nop__12BitSubStringRC9BitStringopZassign_nop__12BitSubStringRC12BitSubStringat__9BitStringiibefore__9BitStringiafter__9BitStringiat__9BitStringRC9BitStringibefore__9BitStringRC9BitStringiafter__9BitStringRC9BitStringiat__9BitStringRC12BitSubStringibefore__9BitStringRC12BitSubStringiafter__9BitStringRC12BitSubStringiat__9BitStringRC10BitPatternibefore__9BitStringRC10BitPatterniafter__9BitStringRC10BitPatternicommon_prefix__FRC9BitStringT0icommon_suffix__FRC9BitStringT0ireverse__FRC9BitStringBitStringtoa__FRC9BitStringccatoBitString__FPCcccopZalshift__FR7ostreamRC9BitStringBitPatterntoa__FRC10BitPatterncccatoBitPattern__FPCccccopZalshift__FR7ostreamRC10BitPatternOK__C9BitStringOK__C12BitSubStringOK__C10BitPattern_GLOBAL_ZDZerror__C9BitStringPCc_GLOBAL_ZIZerror__C9BitStringPCcopZcall__6Normal_RNGZdoubleMantissaopZcall__9LogNormal_RNGZsingleMantissaopZcall__14NegativeExpntl_RNGZdoubleMantissa_RNGZsingleMantissaopZcall__7Weibull_RNGZdoubleMantissa_RNGZsingleMantissaopZcall__6Erlang_RNGZdoubleMantissa_RNGZsingleMantissaopZcall__15DiscreteUniform_RNGZdoubleMantissa_RNGZsingleMantissaopZcall__7Uniform_RNGZdoubleMantissa_RNGZsingleMantissaopZcall__7Poisson_RNGZdoubleMantissa_RNGZsingleMantissaopZcall__14HyperGeometric_RNGZdoubleMantissa_RNGZsingleMantissaopZcall__9Geometric_RNGZdoubleMantissa_RNGZsingleMantissaopZcall__8Binomial_RNGZdoubleMantissa_RNGZsingleMantissa__3RNG_RNGZdoubleMantissa_RNGZsingleMantissarandomPermutations__3ACGUlireset__3ACG_Z_ACGasLong__3ACG_RNGZdoubleMantissa_RNGZsingleMantissa__4MLCGllreset__4MLCGasLong__4MLCG_RNGZdoubleMantissa_RNGZsingleMantissadefault_SampleStatistic_error_handler__FPCcSampleStatistic_error_handlerset_SampleStatistic_error_handler__FPFPCc_verror__15SampleStatisticPCctval__Fdireset__15SampleStatisticopZassign_plus__15SampleStatisticdmean__15SampleStatisticvar__15SampleStatisticstdDev__15SampleStatisticconfidence__15SampleStatisticiconfidence__15SampleStatisticd__15SampleHistogramddd_Z_SampleHistogramopZassign_plus__15SampleHistogramdsimilarSamples__15SampleHistogramdprintBuckets__15SampleHistogramR7ostreamreset__15SampleHistogramSampleHistogramMaximumSampleHistogramMinimumFix_default_lengthFix_default_print_widthFix_overflow_handlerFix_overflow_saturate__FRP5_Frep_Frep_0_Frep_m1_Frep_quotient_bumpdefault_Fix_error_handler__FPCcdefault_Fix_range_error_handler__FPCcFix_error_handlerFix_range_error_handlerset_Fix_error_handler__FPFPCc_vset_Fix_range_error_handler__FPFPCc_verror__3FixPCcrange_error__3FixPCcnew_Fix__FUsnew_Fix__FUsP5_Frepnew_Fix__FUsdvalue__FR3Fixmantissa__FR3Fixcompare__FP5_FrepT0add__FP5_FrepN20subtract__FP5_FrepN20multiply__FP5_FrepN20negate__FP5_FrepT0multiply__FP5_FrepiT0divide__FP5_FrepN30shift__FP5_FrepiT0atoF__FPCciFtoa__FR3FixiopZassign_trunc_mod__3FixiopZarshift__FR7istreamR3Fixshow__FR3Fixset_overflow_handler__FPFRP5_Frep_vFix_set_default_length__FiFix_overflow_wrap__FRP5_FrepFix_overflow_warning_saturate__FRP5_FrepFix_overflow_warning__FRP5_FrepFix_overflow_error__FRP5_Frepassign__5Fix16drange_error__5Fix16Rsassign__5Fix32drange_error__5Fix32RlopZmult__FR5Fix32T0opZtrunc_div__FR5Fix16T0opZtrunc_div__FR5Fix32T0overflow__5Fix16RsFix16_overflow_handleroverflow__5Fix32RlFix32_overflow_handlerFix16_range_error_handlerFix32_range_error_handlerFix16_overflow_saturate__FRsFix32_overflow_saturate__FRlFix16_warning__FRsFix32_warning__FRlset_Fix16_overflow_handler__FPFRs_vset_Fix32_overflow_handler__FPFRl_vset_overflow_handler__FPFRs_vPFRl_vset_Fix16_range_error_handler__FPFRs_vset_Fix32_range_error_handler__FPFRl_vset_range_error_handler__FPFRs_vPFRl_vFix16_ignore__FRsFix16_overflow_warning_saturate__FRsFix16_abort__FRsFix32_ignore__FRlFix32_overflow_warning_saturate__FRlFix32_abort__FRlassign__5Fix24drange_error__5Fix24Rlassign__5Fix48drange_error__5Fix48R8twolongsopZmult__FR5Fix24T0opZtrunc_div__FR5Fix24T0opZplus__FR5Fix48T0overflow__5Fix48R8twolongsopZminus__FR5Fix48T0opZmult__FR5Fix48iopZalshift__FR5Fix48iopZarshift__FR5Fix48ioverflow__5Fix24RlFix24_overflow_handlerFix48_overflow_handlerFix24_range_error_handlerFix48_range_error_handlerFix24_overflow_saturate__FRlFix48_overflow_saturate__FR8twolongsFix24_warning__FRlFix48_warning__FR8twolongsset_Fix24_overflow_handler__FPFRl_vset_Fix48_overflow_handler__FPFR8twolongs_vset_overflow_handler__FPFRl_vPFR8twolongs_vset_Fix24_range_error_handler__FPFRl_vset_Fix48_range_error_handler__FPFR8twolongs_vset_range_error_handler__FPFRl_vPFR8twolongs_vFix24_ignore__FRlFix24_overflow_warning_saturate__FRlFix24_abort__FRlFix48_ignore__FR8twolongsFix48_overflow_warning_saturate__FR8twolongsFix48_abort__FR8twolongsFix48_m_minFix48_m_maxFix48_lsbFix48_msbFix48_div_lFix48_div_uFix48_minFix48_maxFix48_fsFix24_m_minFix24_m_maxFix24_lsbFix24_msbFix24_minFix24_maxFix24_divFix24_multFix24_fs__6GetOptiPPcPc_GetOptZlast_nonopt_GetOptZfirst_nonopt_GetOptZnextchar_GetOptZorderingexchange__6GetOptPPcopZcall__6GetOptEHSexceptionHandlerStack__16ExceptionHandler_Z_ExceptionHandler_GLOBAL_ZDZEHS_GLOBAL_ZIZEHS__unhandled_exception__1xyzzy___GLOBAL_ZDZ__1xyzzy___GLOBAL_ZIZ__1xyzzy____main__dli__dlp__do_global_initexit__do_global_cleanupchr__Fcidtoa__Fdciidefault_one_arg_error_handler__FPCcdefault_two_arg_error_handler__FPCcT0lib_error_handlerset_lib_error_handler__FPFPCcPCc_vform__FPCcegcd__Fllhashpjw__FPCcmultiplicativehash__Fifoldhash__Fditoa__Fliiitoa__FUliiitoa__Fxiiitoa__FUxiihex__Flioct__Flidec__Flihex__FUlioct__FUlidec__FUlilg__FUl_libgxx_fmtq_GLOBAL_ZDZ_libgxx_fmtq_GLOBAL_ZIZ_libgxx_fmtq_libgxx_io_ob_GLOBAL_ZDZ_libgxx_io_ob_GLOBAL_ZIZ_libgxx_io_obpow__Fdlpow__Fllsqrt__Flstr__FPCcistart_timer__Fvreturn_elapsed_time__Fdscanw__12CursesWindowPCcemvscanw__12CursesWindowiiPCceprintw__12CursesWindowPCcemvprintw__12CursesWindowiiPCce__12CursesWindowiiii_CursesWindowZcount__12CursesWindowRP7_win_st__12CursesWindowRT0iiiickill_subwindows__12CursesWindow_Z_CursesWindowcurscrstdscrAllocRing.o/ 639038109 103 100 100644 1190 ` R&.text  .data  @.bss  NV/ $n . %@B/N$rlp RB RBPRm $nN^NuNV"n". g pl QgPHRmpN^NuNVH0 $nvl2t RJ(g/0(N RB(XO RB(PRmBL N^NuNVH $n/. / NdPOJm R$/0(N RB(LN^NuNV/$./N`XOJ g /N$.N^NuNV/. /.NJ\pN^NuNVH $n". Xpc ㈲b$Y R"*Jgb 倰c "0`@ R *Jg/0NXO/N" R *! R *!R"jmB LN^Nu   4   .filegAllocRing.cc.text .data .bss  P3EViv@\__9AllocRingi__builtin_newfind__9AllocRingPvclear__9AllocRing__builtin_deletefree__9AllocRingPv_Z_AllocRingcontains__9AllocRingPvalloc__9AllocRingiObstack.o/ 639038177 103 100 100644 1375 ` R&J.text .data@.bssNV n".S!A BBB B N^Nudeletion of nonexistent objObstackNVH0 $n&. jg&ec$(/N BXOfްg%C %C%P%H`JgHzxHz yNL N^NuNVH80&n(+&+ $Ԯ ゴl$/N$@'J%DЂ'@$ +PJXO/// N'J֫'C L N^NuNV/ n$( ( Ш"(F!@ "(l!h !h  $.N^NuNV . "n igbe hfVrN^Nuinvariant failureNVH0 nJ^tĀJVvĀJVĀ (PSĀ&( TvĀ&( SvĀ"h&(WvĀ I <gJgS hfJ^vƒāfHzNHz yN L N^Nu  z .filegObstack.cc.text.data.bssLC%0,LC%1HP#4FZmemcpyh8yLC%2__7Obstackii_free__7ObstackPv__builtin_deletelib_error_handlernewchunk__7Obstacki__builtin_newfinish__7Obstackcontains__7ObstackPvOK__7Obstack File.o/ 639038292 103 100 100644 6792 ` R&T"P.text4 .data @.bssNV/.NBN^NuNVBN^NuNV/.NHxNN^NuNV 9#N^NuNVH0 .$. vb|6; N0J $r`r`r` r `r vb@ 6; N0J $ @` @` ` @`pL N^Nurwr+aa+NV .rbN2; NJ  *4 <`, <`" <` <` <`pN^NuNV nBBBp!@ B(N^Nu(stdin)(stdout)(stderr)(string)NV/ $n . g/`L f Hz`: f Hz`( f Hz`*g Hz`B/ N8$n&n &..Jg& R( g| R( g| pJ f*gpJgBS%CoIJg& R( g| R( g| pJ f*gpJg> RSk RXH"PrR`/NXO"|Wg| $ / NZp XOgp` Jgn.fT.H2HtJVg$*g/HH/N|ftJg| B`SJoI( Jg& R( g| R( g| pJ f*gpJg< RSk RXH"PrR`/NXO"|Wg| / NNp XOgp` Jgb.fN.H2HtJVg$*g/HH/N|ftJg| `SJnBrJg *%@frJg| L|N^NuNVH<8$n&n $..Jg& R( gz R( gz pJ f*gpJgS%BoI& Jg& R( gz R( gz pJ f*gpJg< RSk RXH"PrR`/NXO"zWgz / Np XOgp` JgS.gJnNBrJg *%@frJgz L 8_doscanDvfprintfverbose_File_error_handler__FPCcquiet_File_error_handler__FPCcfatal_File_error_handler__FPCcFile_error_handlerset_File_error_handler__FPFPCc_vopen_cmd_arg__F7io_mode11access_modefopen_cmd_arg__F7io_modeinitialize__4Filereinitialize__4FilePCcsetname__4FilePCccheck_state__4Fileerror__4Fileopen__4FilePCc7io_mode11access_modeclose__4Fileopen__4FilePCcT1open__4FileP6_iobufopen__4Filei7io_mode__builtin_deleteremove__4File__4FilePCc7io_mode11access_mode__4FilePCcT1__4Filei7io_mode__4FileP6_iobuf__4FileiPc7io_mode__builtin_new_bufendtabsetbuf__4Fileisetbuf__4FileiPcput__4FilePCcget__4FilePcicgetline__4FilePcicreadline__4Fileicgets__4FilePPccscan__4FilePCceform__4FilePCceostream.o/ 639038412 103 100 100644 4699 ` R& 9.textt - .datatt @.bssNV n BB( N^NuNVH00&n&. $.B|JfP/EN$XO//HxNXO$@/ N & jB//2h / h$N S|`"//HxNXO$@/ N&B* L N^NuNVH $nB|/././. HxNXO$/N$ LN^NuNVH $nB|/./. HxNXO$/N$ LN^NuNVH $nB|/./. HxNXO$/N$ LN^NuNVH $nB|/. HxNXO$/N$ LN^NuNVH $nB|/. HxNXO$/N$ LN^NuNVH $nB|/././. HxNXO$/N$ LN^NuNV/ $nJ*g"Jg R hHx2h/ h NPOJ g / N$nN^NuNVH $n R h/././. 2h8/ hTVkX  r"1cerrtcout~AbB_iob__7ostreamP9streambuf__7ostreamiPc__builtin_new__9streambufPci__7ostreamPCc7io_mode11access_mode__7FilebufPCc7io_mode11access_mode__7ostreamPCcT1__7FilebufPCcT1__7ostreami7io_mode__7Filebufi7io_mode__7ostreamP6_iobuf__7FilebufP6_iobuf__7ostreami__7filebufi__7ostreamiPci__7filebufiPci_Z_ostream__builtin_deleteopen__7ostreamPCc7io_mode11access_modeopen__7ostreamPCcT1open__7ostreami7io_modeopen__7ostreamP6_iobufopen__7ostreamPCc9open_modeform__7ostreamPCcesputs__9streambufPCcopZalshift__7ostreamsitoa__FliiopZalshift__7ostreamUsitoa__FUliiopZalshift__7ostreamiopZalshift__7ostreamUiopZalshift__7ostreamlopZalshift__7ostreamUlopZalshift__7ostreamxitoa__FxiiopZalshift__7ostreamUxitoa__FUxiiopZalshift__7ostreamf__extendsfdf2dtoa__FdciiopZalshift__7ostreamdname__7ostreamerror__7ostream_GLOBAL_ZDZ__7ostreamP9streambuf_GLOBAL_ZIZ__7ostreamP9streambuf istream.o/ 639038581 103 100 100644 7301 ` R&u@.text`( .data``@.bssppNV n Bn !nB( N^NuNVH08&n&. $.Bn 'n| HxIN$@/ NPO&Jf|/N$XO` SB( S h///2h / h$N L N^NuNV/ $nJ* g"Jg R hHx2h/ h NPOJ g / N$nN^NuNVH $nBn %n| /././. HxNXO$/N$ LN^NuNVH $nBn %n| /./. HxNXO$/N$ LN^NuNVH $nBn %n| /./. HxNXO$/N$ LN^NuNVH $nBn %n| /. HxNXO$/N$ LN^NuNVH $nBn %n| /. HxNXO$/N$ LN^NuNVH $nBn %n| /././. HxNXO$/N$ LN^NuNVH $n R h/././. 2h8/ hHA0gd S"h$(e/ iNXO`R S"h$(e/ iNXO @` hH0@"tftft L N^NuNV/ $nJ* gHy/ NPO/. / ND$nN^NuNVH80&n$n $..vJg( S h2hX/ h\NXOJg JfvJf r`B.& SJoHn/ N @POJgpJg.f S.HH"(bJ`XS`jHn/ N @POJgpJgV.f@ S.HH"(cS hH0@`0|rfr ` SJnBgB L N^NuNVH 0&n$n tJg( S h2hX/ h\NXOJg JftJg f r`J+ g Hy/ NZ @POJVf$ Hn/ N~ @POJgpJgx`R.H2@A0g: S"(cS h0 H0@`0|rfr `$Hn/ N @POJgpJfBgB L N^NuNVH80&n$n $..vJg( S h2hX/ h\NXOJg JfvJf r`B& SJo,Hn/ Nr @POJgpJg.fBgB L N^NuNVH<0&.(. .EH6@`^.gx D oN?T.filegistream.cc.text`(.data`.bssp$&<JWbsJ <O0eqz\*/_ctypeQWShz&P  ~  #7atofHZq8^cin`#*N>cout_ioby__7istreamP9streambufiP7ostream__7istreamiPciP7ostream__builtin_new__9streambuf_Z_istream__builtin_delete__7istreamPCc7io_mode11access_modeiP7ostream__7FilebufPCc7io_mode11access_mode__7istreamPCcT1iP7ostream__7FilebufPCcT1__7istreami7io_modeiP7ostream__7Filebufi7io_mode__7istreamP6_iobufiP7ostream__7FilebufP6_iobuf__7istreamiiP7ostream__7filebufi__7istreamiPciiP7ostream__7filebufiPciopen__7istreamPCc7io_mode11access_modeopen__7istreamPCcT1open__7istreami7io_modeopen__7istreamP6_iobufopen__7istreamPCc9open_modeget__7istreamRcopZarshift__7istreamR10whitespaceopZarshift__7istreamRcget__7istreamPcicopZarshift__7istreamPcgetline__7istreamPcicreadline__7istreamicgets__7istreamPPccopZarshift__7istreamRlopZarshift__7istreamRUlopZarshift__7istreamRd_libgxx_io_obnewchunk__7Obstackifinish__7Obstack_free__7ObstackPvopZarshift__7istreamRiopZarshift__7istreamRUiopZarshift__7istreamRsopZarshift__7istreamRUsopZarshift__7istreamRf__truncdfsf2name__7istreamerror__7istreamtie__7istreamP7ostream_flush__7istream_GLOBAL_ZDZ__7istreamP9streambufiP7ostream_GLOBAL_ZIZ__7istreamP9streambufiP7ostream streambuf.o/ 639038658 103 100 100644 2206 ` R&.text .datapF @.bssttNV n!|BBBB B( N^NuNV/ n"n !| !I!I".E!J B( $nN^NuNV/ $nJ*gJg /NXOJ g / N$nN^NuNV/ $nJ*gJg /NXOHxN$%@%@"%A | <$nN^NuNV n . !@ ".Ҁ!A .АS!@ N^NuNVpN^NuNVH $n$. Jff / NT`prf B`&"* b jH0@R`0| LN^NuNVpN^NuNVH0&n$n ghJgbH0@p"+ d r fpJg, kHH/"K/ hNPOrfp` kRRJJfpL N^NuNVH 0&n$n $.SkhH0@p"+ d r fpJg, kHH/"K/ hNPOrfp` kRRJQBBSdpL N^NuNVpN^NuNVpN^NuNVNN^NuNVpN^NuNVpN^NuNVpN^NuNVpN^NuNVpN^NuNq b*  8~    (08@HPX`hp.filegstreambuf.cc.text.datap .bsst(/b<Mdr *"abort*Hq__9streambuf_vtZstreambuf__9streambufPci_Z_streambuf__builtin_deletedoallocate__9streambuf__builtin_newsetbuf__9streambufPciiname__9streambufoverflow__9streambufiunderflow__9streambufsputs__9streambufPCcsputsn__9streambufPCciis_open__9streambufclose__9streambuferror__9streambufopen__9streambufPCc9open_modeopen__9streambufPCc7io_mode11access_modeopen__9streambufPCcT1open__9streambufi7io_modeopen__9streambufP6_iobuffilebuf.o/ 639038730 103 100 100644 2698 ` R& '.text  .data@@.bssNV/ $n/ N%|r%AB* $nN^NuNV/ $n/ N%|%n | $nN^NuNV/ $n/././ N%|%n | $nN^NuNV n(HHN^NuNVH0$n*H6@g /*NB* L N^NuNVH $n".J*f|ptg"m Jg`$tg`p` <` <Hx//. N%@ \@gJf/ N`p `pLN^NuNV/ $nJ*fp`XJff/ NXO`p j Hh//*N%R"Ғ%AJf 0|` jH0@ $nN^NuNVH $n$. J*gZJff/ NXO`prg jR$*Jo///*N%RJfp`pLN^NuNV/ $n j"J`/ hdNXO%|$g/. / N$nN^NuNq p~  < Bt z>bN  !08"@#HPX$`hpx %&!.filegfilebuf.cc.text.data.bss(.4^CSecloseuopen~readwritep$ G]w__7filebuf__9streambuf_vtZfilebuf__7filebufi__7filebufiPci__9streambufPciis_open__7filebufclose__7filebufopen__7filebufPCc9open_modedoallocate__9streambufunderflow__7filebufoverflow__7filebufi_Z_filebuf_vtZstreambuf_Z_streambufsetbuf__9streambufPciiname__9streambufopen__9streambufPCc7io_mode11access_modeopen__9streambufPCcT1open__9streambufi7io_modeopen__9streambufP6_iobuferror__9streambufoverflow__9streambufiunderflow__9streambufopen__9streambufPCc9open_modeis_open__9streambufclose__9streambufFilebuf.o/ 639038825 103 100 100644 5455 ` R&i 8=.text 6 .data 8 4@.bss NV/ $n jJg PJfB BBB`< j P$ j P( HHC 1SВ%@ %@%@$nN^NuNV nrJg hJVgr N^NuNVH $n$. ". .Jf*///HxNXO$/N%B`////*NJg/ j Hh/*N / N LN^NuNVH $n". .Jf(//HxNXO$/N %B`///*N Jg/ j Hh/*N / N` LN^NuNVH $n". .Jf(//HxNXO$/N %B`///*N Jg/ j Hh/*N / N LN^NuNVH $n . Jf$/HxNXO$/NPO%B`//*NPOJg/ j Hh/*N / N` LN^NuNV/ $n/ N%|B $nN^NuNVH $n/ N%|/././. HxNXO$/N%B/ N LN^NuNVH $n/ N%|/./. HxNXO$/N %B/ N LN^NuNVH $n/ N%|/./. HxNXO$/N %B/ N8 LN^NuNVH $n/ N%|/. HxNXO$/NPO%B/ N LN^NuNVH 0$n"j jJVtĀg Hy&J/ iN/*N L N^NuNV/ $n jJg*"J`/ hdNXOJgHx/*NPO%| g/. / N$nN^NuNVH 8(nJg.Jfr$ltJVg/N%@XOrftJgr $* l P( l P( HHC 1SД)@ `\ l P!l l P , R $ltJVg/N%@XOrftJgr $*)T lrf )T` l P АR)@$l/ GNXO/ NJ Wg ` lB pLN^NuNVH08&n". Jfp` k P( gzJg*vf*$ktJVgD/NXO`0vgp$ktJVg/HH/NPOvftJgv `Jf~vg $ktJVg/HH/NPOvftJgv k P& k P( HHC 1SГ'@ 'S`fvg kR k P!k k P + R $ktJVg/NXOvftJgv k P'h$k/ INXO* f$k/ N* g kB p`pL N^NuNV"n i (N^NuNVH 8(nJfhJgHxN$/NPO)B/. /./,N/ N$l/ GNXO/ NJ Wg `pLN^NuNV n/(NN^Nu n(4p$ H   N Zt T `v  >DX d  ^!#%'B '(p*++( *(2 <.Tj(01     (% 02 83 @4 H5 P1 X6 `7 h8 p9 x: ; <.filegFilebuf.cc.text6.data.bss "-p?ft($94P`t.$n_Z_File (5_filbufI\fflush_flsbufp__4File#Lb|init_streambuf_ptrs__7Filebuf_bufendtabis_open__7Filebufopen__7FilebufPCc7io_mode11access_mode__builtin_new__4FilePCc7io_mode11access_modeopen__4FilePCc7io_mode11access_modesetbuf__4FileiPcopen__7FilebufPCcT1__4FilePCcT1open__4FilePCcT1open__7Filebufi7io_mode__4Filei7io_modeopen__4Filei7io_modeopen__7FilebufP6_iobuf__4FileP6_iobufopen__4FileP6_iobuf__7Filebuf__9streambuf_vtZFilebuf__7FilebufPCc7io_mode11access_mode__7FilebufPCcT1__7Filebufi7io_mode__7FilebufP6_iobufclose__7Filebufclose__4File_Z_Filebuf_vtZstreambuf_Z_streambufunderflow__7Filebufcheck_state__4Fileoverflow__7Filebufiname__7Filebufsetbuf__7FilebufPciierror__7Filebuferror__4Fileopen__9streambufPCc9open_modeoverflow__9streambufiunderflow__9streambufsetbuf__9streambufPciiname__9streambufopen__9streambufPCc7io_mode11access_modeopen__9streambufPCcT1open__9streambufi7io_modeopen__9streambufP6_iobufis_open__9streambufclose__9streambuferror__9streambuf PlotFile.o/ 639038905 103 100 100644 3725 ` R&3.text, .data@.bssNV/$./N $.N^NuNV .g/. /NN^NuNV/$./././. /N $.N^NuNV/$././. /N $.N^NuNV/$././. /N $.N^NuNV/$./. /N $.N^NuNV np gp` N^NuNV/$./././. /N $.N^NuNV/$././. /N $.N^NuNV/$././. /N $.N^NuNV/$./. /N $.N^NuNV/$./. /N $.N^NuNV/$././. /N $.N^NuNVH8 $n.H4HvJg R( gx rp f*grJg8 RSk RXH"PrR`/HH/N"xfvJgx LN^NuNVH< $n(. H4HvJg R( gz rp f*grJg: RSk RXH"PrR`/HH/NPO"zfvJgz H4HvJg R( gz rp f*grJg8 RSk RXH"PrR`/HH/N"zfvJgz L $.&. (.*.,./////EXN/////N(/////N/////NL|N^NuNV/ /././. Hxc/.NDPO/ENPO/NPO/N$nN^NuNV/ /./. Hxn/.N PO/ENPO/N$nN^NuNVH00&.$.&n//././. Hxd/NPO/E^NPO/NPO/NPO/N` //N>PO SJn L N^NuNVHxe/.NxN^Nu NV/ Hz/. Hxt/.NXPO/ENPO/N$nN^NuNV/ /./././. Hxl/.NPO/ENPO/NPO/NPO/N$nN^NuNV/ Hz~/. Hxf/.NPO/ENPO/N$nN^NuNV/ /./. Hxm/.NPO/EDNPO/N$nN^NuNV/ /./. Hxp/.N|PO/ENPO/N$nN^NuNV/ /./././. Hxs/.NBPO/ENPO/NPO/NPO/N$nN^NuNq 0 R v$Hh 0""Z"%.filegPlotFile.cc.text.data.bss__4File_Z_File8@``q~'<M2f{Vv_flsbufX/=Re|yZ4LC%0HJ&X+__8PlotFile_Z_PlotFile__8PlotFilePCc7io_mode11access_mode__4FilePCc7io_mode11access_mode__8PlotFilePCcT1__4FilePCcT1__8PlotFilei7io_mode__4Filei7io_mode__8PlotFileP6_iobuf__4FileP6_iobuftypeZPv__8PlotFileopen__8PlotFilePCc7io_mode11access_modeopen__4FilePCc7io_mode11access_modeopen__8PlotFilePCcT1open__4FilePCcT1open__8PlotFilei7io_modeopen__4Filei7io_modeopen__8PlotFileP6_iobufopen__4FileP6_iobufsetbuf__8PlotFileisetbuf__4Fileisetbuf__8PlotFileiPcsetbuf__4FileiPccmd__8PlotFilecopZalshift__8PlotFileiopZalshift__8PlotFilePCcput__4FilePCcarc__8PlotFileiiiiiibox__8PlotFileiiiiline__8PlotFileiiiicircle__8PlotFileiiicont__8PlotFileiidot__8PlotFileiiiiPCierase__8PlotFilelabel__8PlotFilePCclinemod__8PlotFilePCcmove__8PlotFileiipoint__8PlotFileiispace__8PlotFileiiii SFile.o/ 639038968 103 100 100644 952 ` R&.textl .data@.bssNV/$./N $.N^NuNV .g/. /NN^NuNV/ $n/././. / N%n $nN^NuNV/ $n/./. / N%n $nN^NuNV/ $n/./. / N%n $nN^NuNV/ $n/. / N%n $nN^Nu 0 R |.filegSFile.cc.text.data.bss__5SFile__4File_Z_SFile_Z_File8&FfUbu__5SFilePCci7io_mode11access_mode__4FilePCc7io_mode11access_mode__5SFilePCciT1__4FilePCcT1__5SFileii7io_mode__4Filei7io_mode__5SFileP6_iobufi__4FileP6_iobufregex.o/ 639039124 103 100 100644 9002 ` R&,.textpC .data d@.bssNVJfdHxBHyNpaARrzlpAARrZlp0ARr9lr#N^NuNV 9#N^NuInvalid regular expressionUnmatched \(Unmatched \)Premature end of regular expressionNesting too deepRegular expression too bigMemory exhaustedNVFH?<"n$Q&n$ Ԯ -B\-iXBT~|-JPI`-LLLt-BHB)N"nJf 2t#BJgHx/N"n"PO`HxN"n"XO"nJg f$Q-JP` "nrҩlp& g 0$)#B o #|"n/)/N"n"POg *JgޅJg܅ۮPJTgۮT\gp*JXgp"nX1X*pЅtrb4; N Jt.9g69f \fJg/ Hx/N ~`\g  g9f9g )g` \f +)g9g |g`" \f +|f`Jg + g9g9g& .Rg9g-JP`B`:9fJf9gBB.Grvƹt+g.Gt?g@G\gg2*JXg "nX1X*t*gJft+gt?gJgDt\f<\g JXg "nX1 t+gt?gUK` *`VSKJgXJ.Gg"FHiHx/ NVJ / $ V//HxKNBT$BJf/ "FHi/HxNVJ`,  `"n& gJ$)#B o #|"n/)/N"n"POg*JgޅJg܅ۮPJTgۮT" "npЩm|, ^f  RK` *K Hx B/ N v\g*JXg "nX1X*t]f Rf -fh +]g^\gF(JXg "nX1H\g*(JXg "nX1H(e r…t㢅2Rd`d r…t㢅2`P*HJ2fS*J*n*H`b9g`9g`j9g`9g`\gRglp*pЅtUbn4; N JW^R^^^^^^^^R^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^9fLgt Hm  K$ "n( LXLJg R`p (HRH$.P"n(~`9fD `g"n$Ԥ-BPJg/ Hx/N2 t m  QL~Jg"n Д.S"n,ܤ`v9f/ Hj/.PHxNBTVJJg/ Hx/N . VJ|-JP`*, ` , ```````x؅HdXA `d `g8e, `9flJXgp"nX1X*JTgh"nTHAfV gN *gF ^g>9g" \f6 ++g +?g` +g ?f, -JTB"nTR\fJg/ Hx/Nl `f"n#Jp`D <`: <`0 <`& <` <` <` <L<N^NuNV/ n .4AW@$.N^NuNV/. ". ."@VI @g  f/.HH//N$.N^NuNVH<< n&h $P( ب(hKHxB/ N n|B(gvCf n|` Szb:; NPJ4^Dfg*p48`$*8`g, 8`| n (g|` n|"HHҀEJn fRJ"HH AA gf`"HHҀXMҊ*`RJ`~ n|| rz gR o nJ(fN`0r 1fR o`r 1gR o` "Skt l^2 l^zDgg4(`Sj`" n,pg4`R o "SkJt l^2 l^zDfg4(`Sj g$UYMfFL<&G*gJg"n1H` g`\t , ft` g&G*gJgp"n1H"`" 瀰o. l^4 l^vDg JWtĀIHJgRK`ҷg + g`pgfJg"G  g`J  g`>fn ."9ひlp`L .&-C"Rvƒ$//./N v*B&.ւ-C-B$DHH**`$DHH L g  g  f RH f g g f fp `( "A (f (fb ( g ( fT ( WtĀ( 瀰o. l^0 l^vDg JWtĀJf|UL ,g |`QM$DHHA`fP .&-C"Rvƒ$//./N v*B&.ւ-C-BBB`ggf Jgt+C 1HWvƒf "G`C 1HWvf2`gڷgҷf Jg+C 1HWvƒf "G`C 1HWvf`ȷgtf Jgdf G` KC 1HfBg+`Pg*+C 1HfgZf JgJf "G`C 1Hf&`ּg&G*gCJ1Hg`g&G*gCJ1Hf`ڷg`gƷfrJg`f$DJg@p` gN&G*g"n1f4SJf`rg &G*g fSJf`Ng,JfQM`&e(ee,b$*.`pLHxN$XOg"E$HxN%@XOf <`Hy/NXO//NLN^NuNV/$./NB/B//HyNJ\p$.N^NuNq $<Tlzlx0<Ttf L\l|f 8  \          %>z&&FlD(8HVfv**.filegregex.cc.textC.data .bssdone_%0memset)8tLC%0LC%1LC%2LC%3LC%4LC%5LC%6J reallocwLI%192t , ^LI%186 LI%290  GLI%511memcmpmemcpyLC%7 strleninit_syntax_once__Fvre_syntax_tableobscure_syntaxre_set_syntax__Fire_compile_pattern__FPciP17re_pattern_buffer__builtin_newstore_jump__FPccT0insert_jump__FcPcN21re_compile_fastmap__FP17re_pattern_bufferre_search__FP17re_pattern_bufferPciiiP12re_registersre_search_2__FP17re_pattern_bufferPciT1iiiP12re_registersire_match_2__FP17re_pattern_bufferPUciT1iiP12re_registersire_match__FP17re_pattern_bufferPciiP12re_registersre_max_failuresbcmp_translate__FPUcT0iT0re_comp__FPcre_comp_bufre_exec__FPcString.o/ 639039654 103 100 100644 20353 ` R&=d.text78v .data77L8|@.bss8<8<invalid indexNVB n"X/NN^NuStringNV/. Hz yNN^NuRequested length out of rangeNVH<0&n*. &.(.7fJlJfv` EJf R&o(gp0+lNp Єtc ㊰bY cHz^Hz: yNPO/N @B1B$HXO`$K4"EA gSkQB@SdBgg / N L p0+m2 Xbp0Ab Xb\p0AcNp Ѓtc ㊰bY cHzHzl yNPO/N @B1B$HXO`$K4"FA gSkQB@Sd"DA gSkQB@Sd"EAA gSkQB@SdBgg / N LfJgHt/ N&@PO"nAX gSkQB@SdB0 L6*n U2(Se:0E"UXI Up0gSkQB@SdB/ N`*n/N* L  Np  Lv z" . d( 4  `' (+-lHJ !4!"x#.#$%:%&'P'()J*0*<**+ +RW,8,D,Z-hZ-Z../0/DW/0&0b0c1Z1Rd2Hd5 555556666"6,686667767V7t777.filegString.cc.text7v.data7L.bss8<LC%0LC%1("05G7R7LC%2H]ft^d\tP1Gg B  (    _Z_RegexLC%36cL F\wvN` N.=`SlT.`0 <N h!{""#z$6$%&D&4'K(>[(m)*L*lmul,T,_ctype-0 -".1/H/e00WS12v3*03B3T4TLC%44d4LC%55q5$5RXwhite7RXint8RXdouble8 RXalpha888"8*825LC%66DLC%76NLC%86WLC%96LC%106LC%116LC%126LC%1366typeZPCc__C6Stringstr__FPCcierror__C6StringPCclib_error_handler_nilStrRep_nilStringSalloc__FP6StrRepPCcii__builtin_new__builtin_deleteSresize__FP6StrRepiScopy__FP6StrRepT0Scat__FP6StrRepPCciT1iScat__FP6StrRepPCciT1iT1iSprepend__FP6StrRepPCcifcompare__FRC6StringT0compare__FRC6StringPCccompare__FRC6StringT0compare__FRC6StringRC9SubStringcompare__FRC9SubStringRC6Stringcompare__FRC9SubStringT0compare__FRC9SubStringPCcsearch__C6Stringiicsearch__C6StringiiPCcimatch__C6StringiiiPCciassign__9SubStringP6StrRepPCciinitialize__5RegexPCciiiT1re_compile_pattern__FPciP17re_pattern_bufferre_compile_fastmap__FP17re_pattern_buffermatch_info__C5RegexRiT1isearch__C5RegexPCciRiire_search_2__FP17re_pattern_bufferPciT1iiiP12re_registersimatch__C5RegexPCciire_match_2__FP17re_pattern_bufferPUciT1iiP12re_registersi_gsub__6StringPCciT1i_gsub__6StringRC5RegexPCcidel__6Stringiidel__6StringRC5Regexidel__6StringPCcidel__6StringRC6Stringidel__6StringRC9SubStringidel__6Stringciat__6Stringiibefore__6Stringithrough__6Stringiafter__6Stringifrom__6Stringiat__6StringRC6Stringiat__6StringRC9SubStringiat__6StringRC5Regexiat__6StringPCciat__6Stringcibefore__6StringRC6Stringibefore__6StringRC9SubStringibefore__6StringRC5Regexibefore__6Stringcibefore__6StringPCcithrough__6StringRC6Stringithrough__6StringRC9SubStringithrough__6StringRC5Regexithrough__6Stringcithrough__6StringPCciafter__6StringRC6Stringiafter__6StringRC9SubStringiafter__6Stringciafter__6StringRC5Regexiafter__6StringPCcifrom__6StringRC6Stringifrom__6StringRC9SubStringifrom__6StringRC5Regexifrom__6Stringcifrom__6StringPCcisplit__FRC6StringP6StringiT0split__FRC6StringP6StringiRC5Regexjoin__FP6StringiRC6StringSreverse__FP6StrRepT0Supcase__FP6StrRepT0Sdowncase__FP6StrRepT0Scapitalize__FP6StrRepT0replicate__Fcireplicate__FRC6Stringicommon_prefix__FRC6StringT0icommon_suffix__FRC6StringT0iopZarshift__FR7istreamR6StringopZarshift__7istreamR10whitespaceget__7istreamRcreadline__FR7istreamR6StringciopZalshift__FR7ostreamRC9SubStringfreq__C6StringRC9SubStringfreq__C6StringRT0freq__C6StringPCcfreq__C6StringcOK__C6StringOK__C9SubStringOK__C5RegexRXlowercaseRXuppercaseRXalphanumRXidentifier_GLOBAL_ZDZerror__C6StringPCc_GLOBAL_ZIZerror__C6StringPCc Integer.o/ 639040109 103 100 100644 20916 ` R&mFU.textAA~ .dataAA@.bssAAoperation on uninitialized IntegerIntegerRequested length out of rangeNVH80&n(.&.gp0+lT r Ёtc ㊰bY cHzHz yNPO/N @ ]1@$HXO`$K45n"n A Sk0QB@Sd Ap0Cc BXbgg / N L N^NuNVH0 n&. gp0(l^g /NXO r Ёtc ㊰bY cHzHz yNPO/N @ ]1@"H23|Ap0Ec BXb L N^NuNVH<0&n(. fZBC z Ѕtc ㊰bY cHz Hz yNPO/N @ ]1@$H5|`6p0+l z Ѕtc ㊰bY cHzHz yNPO/N @ ]1@$HXOCAp0Sk0QB@Sd5k/ N`$K04r2Ar2Cc BXb L n". \zʀg$`$DBDJg,v, 6"=RD |$fڰg hc`g /NXOp0| Іtc ㊰bY cHzAHz5 yNPO/N @ ]1@$H45ECAp0Sk0QB@Sd L|N^NuNV/ .f:tY cHzHz yNPO/N @ ]1@` @BP1| $.N^NuNV/ ng JhfHg /NXOtY cHzSHzG yNPO/N @ ]1@1n01| $.N^NuNV/ n Pc hff <`JPfp`t Pb$p0r20 hf `P `Hp0( c hf <`& <`"tp0( hgD$.N^NuNV np0rl:rm8 hc(Jhf& hfp\HJPfTHRJop`pN^NuNVH?0&nBB,<~v6Sk4< E////NJm"Jkf Jg C`C ( ؀Jg A` n\H *ڀ7nrc8vt64 DҀ, 4 |"bJf2tc*4", 4 |"gԱgc 4غbr2 AJoJ`f SJn06f7| L*kW~-@WzʀW|̀W~JgJf/.N-@`~f kf/ `~f jf/ /.Nb-@`JgJfPJfJg//.N` //.NF-@PO n\H Ј-@Jg K-H(M, \ `XJg K-H(M`:m UK\K-K(K, \ ` UK\J-J(J, \ (؀ep0*UL$MUMBRJgtt&Fc8v6//NPO6ЃԀ. 4 ~$bJg.rd$2ԁ. 4 ~$fعdt``//.N-@.\-G ހ-G"nEPOJg -n`\K-K "nC, *Fez(F&M:p0//NPO(BRv J6"҃. 4TH ~"g.td$4҂. 0 ~"fطdv J6"҃. 4TH ~"g.td$4҂. 0 ~"fULTKb6://NPO(`4cUM`UUJd"n3nr2 AJoJ`f SJn0"n2f3| .L1nf 8|`."."n<1 ~<1<.//NPO8@z:.. > &GE/ /NPO$. =@~:.< / /NPOԀ. =@~=Bxvp$n ntr SJo4"2 &gJoSL`l$n &nrvdbx$~8 <//NPO"҂. 8< Dր. 6 ~&e ~<Dր. 6 ~&fNSL$n &nvd2xt ~84"҂&ր. 6eBSJg "n3SMUSlL0$. . :.".Jg Efp`Jg\(U$D&Bvbt |4&UK4//NPO,"4UJ//NPOc`D&BEvb4t |4&UJ4//NPO//NPOc"p0L |N^Nuattempted division by zeroNVH?<(.*. &nJfHzHz yNPOJfHzlHz yNPO|"D<v"E6JfHzHzg yNPO//N""D0i"E2iPOW~΀-GJl/ NL&@`Jf/./ N&@`~f*// N&@\/r"E2)/r2//N"`̛"p"E01"@Hi/<NPO @ff&/ t4//E:N(@/ //N*@`(E// Np*@PO$R// Nz&@/Hk/HlHmN,g / NXO/ N7nr2 AJoJ`f SJn06f7| L&@`Jf// N&@`~f(/ / N&@\/r2./r2//N`•"p06*@Hm/<NPO @gbv6p0.E//NPO$. =@~p0.//NPOԀ=BB// N$@ `/ / N6$@PO$R// N@&@/Hk/HnHjN/ N7Dr2 AJoJ`f SJn06f7| L// N(@\/r2-/r2//N"$// N&@Jg7J`z"p05"@Hi/<NPO< Ffgf&/t4// E N*/ //N&@`* // NV&@PO$.R// N^(@/Hl/"EHiHkNg /NXO FgHr2 AJoJ`f SJn06f7| \/r2/r2//N9nr2 AJoJ`f SJn08f9|"n"r2 AJoJ`f SJn06f7|"n"LX2ǰbcHBYb`<>X2ǰbc*2ڲb`>8G2ǰbc 2ڲbr2 AJoJ`f SJn06f7| LF2ưbc 2ڲbr2 AJoJ`f SJn06f7| LN^NuNVH $.$n fHzHz% yNPO// N$@Ap0Cc FXb0BAJ@gIfAHf0r2 AJoJ`f SJn04f5| LN^NuNVH00$n . m$vƀJf&BHkBNx`" Rp0o"Ro //N$  Rp码h"Rr2 AJoJ`f SJn02f3|L N^NuNVH00$n . m$vƀJf&BHkBN`" Rp0o"Ro //Nh$  RpF@h"Rr2 AJoJ`f SJn02f3|L N^NuNVH0 n . Jg4Jm."vƀt Pp0op00gt `pL N^NuNVH?<$n*n fHzHz yNPOfHz˰Hz yNPO, <&F~>Jf/ Hx/ Hj`f/Hx/HmBN˰`./ Hx/ HjBE˚N(@/Hx/HmBN*@B(m$K`$G|-Fxovz, \-FAJg`o : `p&o"n: `p"t g B`RR|lTTHRnJg$/ $.D// EN(@/ // N*@,gp0/JmW|†//Hm`p0/2l/ /HlBNʄ$@JRgzv|-F:.xo>tAJg04 rg B`RR|lTHRnJg/ D// N$@ jf&/ / N(@/ Hx/ B/ N$@`4:/JjW|//Hj/ N*@/ B/ B/ Nּ$@(JRf4/ EN/ NPOJg/ /./ NB(@ L0$n&. &nfHzǔHzdz yNPO jg fz`zx8Jg|f jf// N&@`JgJl/ Nr&@`|g |f/ / N$&@`/ N @/HhNPO$l|ԆT/Hx/HjBN $@4// N&@ Hx/ NV&@POg/ / / Nۂ&@ g/ / / Nl$@ `/ N7Er2 AJoJ`f SJn06f7| L |N^NuNVH $.$n fHz&HzE yNPOg // N$@5| LN^NuNVH $.$n fHzHz yNPOg // N$@JRgJjW@5@ LN^NuAttempted square root of negative IntegerNVH8&I(n/BNr& PO TJPfp` T hfp`pJl Hz/ N(Jg/NXOJlR/D//N & EB B//NL$ E`:/B/B/N"&/Hy/N& ///N $ //NϴPOJ]f/.N LN^NuNVH80$n(. / N$/N @Hh/NPOJlrЁ&@HkBN^"@gHA0gARJH0f -f BRJ` +f <RJ`< /o 9nH0@t`6 `o znH0@t` @oF Zn>H0@tԈo./ // N,"@/ /B/ NԦ"@H3ARJ`~ L N^NuNVH?<.. /Nr"n2R//NPO @"nE/ HyN @E*JB" "nJQf <0`(/.BN&@|://<NPO6POEct4//NPO:REbI/ p0/p0// N&r2 AJoJ`f SJn06f7|JSfLJg://NPO//NPO&  o W`0Jf/ N`Hxob//NPO//NPO&  o W`0Rn`$"nJif<- S`< "Rm L 4X 6778 8t 9'99 :* ;x;D;E;';F;F<E<H<I=J=>*=X'=K=H=>K> H?*P?2Q?RA .filegInteger.cc.textA~.dataA.bssALC%0LC%1#LC%2+J/=N.bvJB__cmpdf2__muldf3__adddf3__negdf2'<%D__divdf3] s    RDlmul (uldiv@`LC%3DU`o ("L'),.2.\20&N1h2|3(346A78N 9#: LC%4:b>:P;strlenlg__FUl_ctypea<ldivtlrem>>>>WS LC%5@F@X*Ialloc__FP6IntRepPCUsiiilib_error_handler__builtin_new__builtin_deleteIcalloc__FP6IntRepiIresize__FP6IntRepiIcopy__FP6IntRepPC6IntRepIcopy_long__FP6IntReplIcopy_zero__FP6IntRepIcopy_one__FP6IntRepiItolong__FPC6IntRepIislong__FPC6IntRepItodouble__FPC6IntRepIisdouble__FPC6IntRepratio__FRC7IntegerT0divide__FRC7IntegerT0R7IntegerT2compare__FPC6IntRepT0ucompare__FPC6IntRepT0compare__FPC6IntReplucompare__FPC6IntRepladd__FPC6IntRepiT0iP6IntRepadd__FPC6IntRepilP6IntRepmultiply__FPC6IntRepT0P6IntRepmultiply__FPC6IntReplP6IntRepdo_divide__FPUsPCUsiT0iunscale__FPCUsiUsPUsdiv__FPC6IntRepT0P6IntRepdiv__FPC6IntReplP6IntRepdivide__FRC7IntegerlR7IntegerRlmod__FPC6IntRepT0P6IntRepmod__FPC6IntReplP6IntReplshift__FPC6IntReplP6IntReplshift__FPC6IntRepT0iP6IntRepbitop__FPC6IntRepT0P6IntRepcbitop__FPC6IntReplP6IntRepccompl__FPC6IntRepP6IntRepsetbit__FR7Integerlclearbit__FR7Integerltestbit__FRC7Integerlgcd__FPC6IntRepT0lcm__FRC7IntegerT0error__C7IntegerPCclg__FPC6IntReppower__FPC6IntReplP6IntRepabs__FPC6IntRepP6IntRepnegate__FPC6IntRepP6IntRepsqrt__FRC7IntegeratoIntRep__FPCciItoa__FPC6IntRepii_libgxx_fmtqalloc__9AllocRingidec__FRC7Integerioct__FRC7Integerihex__FRC7IntegeriopZarshift__FR7istreamR7IntegeropZarshift__7istreamR10whitespaceget__7istreamRcOK__C7IntegerRational.o/ 639040342 103 100 100644 7063 ` R&VB.text$X .data @.bssNV nHh/NN^NuRationalNV/. Hz yNN^NuZero denominator.NVH<*nC QJPfp` Q hfp`pJf Hz/ NJl E//GN$PO//N*POIGB//N&PO/9/NPOJg$///EN* ///N( /.NL<N^NuNVH0<&.$. gtgl$BXJ n// CX/GN n *C(HXL/ B//N( n/B/B/N n ///N( `|EB &CXKB BX//IN$ *B n// C/N n /B/B/N n XH-H///N n /NXO/.N,L< N^NuNVH0<&.$. gvgn$BXJ n// CX/GN n *C(HXL/ B//N( n/Hx/B/N n ///N( `~EB &CXKB BX//IN$ *B n// C/N n /Hx/B/N n XH-H///N n /NXO/.NL< N^NuNVH<&n(n $n///KN$ JXH-H///N n / NL<N^NuNVH<(n*ng@ g8/"n /)/EN* LG/"n //N& `TEB B"n /)/GN$ LI//"n /N( //N*PO/NXO/ N L<N^NuNVH<$I&n/BKN$POI/BN(PO //N$ L<N^NuNVH<*I$n/BIN*POG/BN&PO UJPfp` U hfp`pJl//N* L<N^NuNVH<$I&nBIB ///KN$ ///N( / N L<N^NuNVH<*nE/BGN$ POI//N*PO//N @(PO"LJPfp` Q hfp`pJf Hz/ NfJl E//GN$PO//N*PO/.NL<N^NuNVH <&n*n SJPfp` S hfp`p" UJPfp` U hfp`p$fXJgREBB/-/IN$ KGBB//N& //N$PO/GNXO/N L<N^NuNVH?8(n$. &.B EB B/GN(POHx/N$POBB//ENJg&BB//NJ]|̀g//NPO$&Hn//N$@&A$.z ~`x RxmB/<@/ / N$@&AHn/ / N$@&A ///N( /./.NPO//B/N(xԄBB/ / NJftJo///N(`JlE/D//N$ Jg//N(PO/ N LN^NuNVH0$I&nB AB // Hk/ N SJPfp` S hfp`pJlFC QJPfp` Q hfp`pJg/HyB/N$/.N L N^NuNVH0$I&nB AB // Hk/ N SJPfp` S hfp`pJmDC QJPfp` Q hfp`pJg/HxB/N$/.N L N^NuNVH<(I*nB EB / / G/ / N/Hx/N$ //NPOJmL UJPfp` U hfp`pJm /Hx` /HyB/N(/.N L<N^NuNVH0&I nEBB/(/N$ /BN& PO/N L N^NuNVH <$ n /NXO//.E"JNXPO/BIN B PO&BXKK/BN&PO g /NXOg /N L<N^NuNVH <(I*n$. BGB Jm$///EN( M///N`pDE///GN$ M///N( "J QJPfp` Q hfp`pJl//EN(POG//N& L<N^Nu/NVH00$n&n Hx/+NPOJWgBHx /`BHx /N tJf//NPOvftJgv < tJf//NPOvftJgv BHx /+N tJf//NvftJgv L N^NuNVH0&n$n / / NPOJf `pJg~B.Hn/ NPO ./fHj/ N/ N`L S.HH"(cS hH0@`0|rfr XJHx/N$ L N^Nuinvariant failureNVH80&nt/ ENXOJgHkNXOJgt&C QJPfr` Q hfr`rJ^xƀEB/+/N$PO/9/N$PO/NXOJWƀf HzL/ N L N^NuNV/9NN^NuNV/ EHxBN$$nN^Nu 0 J`.b,8b$fj!#$,%@&r'()*+$))(h-+ - +  - )  6+ F t   2    L4 t4  7 &8 >9 ^ r9 8 9 ; < 2; # ?"*6djz#.filegRational.cc.textX.data.bssLC%0,"A_Int_OneLC%1:SLh0,NFlNP  -__cmpdf2__negdf2frexp__muldf3modfD`jB  V $ 7LC%2 R t LC%3  ^?r_typeZd__C8Rationalratio__FRC7IntegerT0error__C8RationalPCclib_error_handlernormalize__8Rationalnegate__FPC6IntRepP6IntRepgcd__FPC6IntRepT0ucompare__FPC6IntRepT0div__FPC6IntRepT0P6IntRep__builtin_deleteadd__FRC8RationalT0R8Rationalmultiply__FPC6IntRepT0P6IntRepadd__FPC6IntRepiT0iP6IntRepsub__FRC8RationalT0R8Rationalmul__FRC8RationalT0R8Rationaldiv__FRC8RationalT0R8RationalIcopy__FP6IntRepPC6IntRepopZnegate__FRC8Rationalabs__FRC8Rationalsqr__FRC8Rationalinvert__8Rationalcompare__FRC8RationalT0compare__FPC6IntRepT0__8RationaldIcopy_long__FP6IntRepllshift__FPC6IntReplP6IntRep__fixdfsiadd__FPC6IntRepilP6IntRepfloor__FRC8Rationaldivide__FRC7IntegerT0R7IntegerT2ceil__FRC8Rationalround__FRC8Rationaltrunc__FRC8Rationalpow__FRC8RationalRC7IntegerItolong__FPC6IntReppow__FRC8Rationallpower__FPC6IntReplP6IntRepopZalshift__FR7ostreamRC8Rationalcompare__FPC6IntReplItoa__FPC6IntRepiisputs__9streambufPCcopZarshift__FR7istreamR8RationalopZarshift__FR7istreamR7Integerget__7istreamRcOK__C8RationalOK__C7Integer_GLOBAL_ZDZerror__C8RationalPCc_GLOBAL_ZIZerror__C8RationalPCc Complex.o/ 639040496 103 100 100644 8045 ` R&;.textm .data@.bss  Fatal Complex arithmetic error. NVH A <tJf//NPOrftJg rEtJf/./NPOrftJgr <!tJf//NPOrftJgr HxNLN^NuNV 9#N^NuNV/. yNN^NuAttempted division by zero.NVH?<-I*n "-$-&- E////N(*////N////N-@-ABB/./.NJfHzh/.NLPOE n "( n&((( -C-D-m-m G/-///N,././././.N////NI/././/N-@-A n ("( n-P-h-m-m /-///N,././././.N////N/././/N$%n%@%A &(* n !D&*(* n!C!D Ld.X<X J\"b ##0 B"" #  d  x" ~  # <) R v* +   )  * ( B `+      )   /4~llP" B5Nb 5 789:7<7:.filegComplex.cc.textm.data.bss LC%0LC%1!$cerr(exit=SwLC%2*__muldf3__adddf3__cmpdf2__divdf3__subdf3__negdf2$expcossin5.coshsinhGYj JLC%3 { hypotlogatan2LC%4   sqrt LC%5LC%6LC%7WS<Lcdefault_Complex_error_handler__FPCcsputs__9streambufPCcComplex_error_handlerset_Complex_error_handler__FPFPCc_verror__C7ComplexPCcopZtrunc_div__FRC7ComplexT0opZtrunc_div__FdRC7ComplexopZtrunc_div__FRC7ComplexdopZassign_trunc_div__7ComplexRC7ComplexopZassign_trunc_div__7Complexdexp__FRC7Complexcosh__FRC7Complexsinh__FRC7Complexcos__FRC7Complexsin__FRC7Complexlog__FRC7Complexpow__FRC7ComplexT0sqrt__FRC7Complexpow__FRC7ComplexlopZalshift__FR7ostreamRC7ComplexopZalshift__7ostreamdopZarshift__FR7istreamR7ComplexopZarshift__7istreamR10whitespaceget__7istreamRcopZarshift__7istreamRd BitSet.o/ 639040695 103 100 100644 7501 ` R&3.text" .data@.bssIllegal bit indexillegal bit indexBitSetNV/. Hz yNN^NuRequested length out of rangeNVH<0&n*. (.&.f˶gp0+nb r Ёtc ㊰bY cHzHz` yNPO/N$@XO/B/ N ]5@`$K45nJg \g///N gg / N L 0&n$n S"R<)he> Sx8 Rv6 S\H"R\I $Ԁ * ڀcc02@Agp`8f S"R<)hT`o SJhW|` Rp0(L |N^NuNVH?8&n$n S"R>)heB Sz: Rv6 S\H"R\I (؀ I|c(c"402@Agp`XAg|`ֶf(p"S R>(ibJg.if&p` o SJhW~` Rp0(LN^NuNV/ $I$ HxBHxHn BN$"@r2 AJif*Jo*0UHf"SJn`0UH @f SJn2 $nN^NuNVH0 $I .$" r2v$.-B-B=@HxBHxHnBN,$"@r2 AJif*Jo*0UHf"SJn`0UH @f SJn2 L N^NuNV/ "n Q hg $Q\J Qp0Ab0UHgp`p$nN^NuNVH> $n". Rp0(fp`xv"R\I Rp0* ڀ|f2cV0rJ@ggRHR|l溉b`,8<c"4r0DfRJR|l캉b L|N^NuNV/ $n"n / / N"@JjW@3@Ap0ЈJQf 0` FXbr2 AJif*Jo*0UHf"SJn`0UH @f SJn2 $nN^NuNVH?<*n &n.W~-@W-@B(n=lB=mB=Tv6n $.`$// N&@A $Ԁm@Jg$H`$n\J,. ." ҀJg C`C&.`HJg E`E,. " ҀJg C`"n\I&. -f<D DgHn &g" -g`n ^g |gH`ZF7Cc>Y0DzbJgc60ٴb`*c$BXb`F7Cc>Y0DzbJgc0b`洈c0ٴb`ԽC7Cc>8G0DzbJgc>FG0Ǵb`c0ٴb`0F@F7@c0F@Z0bJgcb>FG0Ǵb`RcLBXb`@0F@C7@c0F@Y0bJgcBXb` 0ٴbr2 AJkf*Jo*0UHf"SJn`0UH @f SJn6 L0$n . ".Jml Hz/ N(zʀ RJhg p0ot$vƁ Rp0n&BHk/N$ \ @,<"p,<&f 0CP` X \"@҇Qc 0bL |N^NuNVH>0$n . ".Jml Hz/ N8&zʀ RJhf p0o|$xȁ Rp0n&BHk/N$ \ @,<"p,<(f0DF@P`&0F@X \"@0F@Qc BXbL |N^NuNVH>0$n . ".Jml HzH/ Nn(vƀ$zʁ Rp0n&BHk/Nb$ \ @,<"p,<&f 0CP`X \"@ҷQc FXbL |N^NuNVH>"n . $.Jmm&zʀ Qp0n p0(`"xȂ Qp0nJhfh Qr2Sx \ @,<$p,<(f0PDV|`40Xf \Б"@0Qf `JXgp` bpL|N^NuNVH>"n*.". R vƁ Qx8np0(f `$ Q\H"p002 |fr|m &JAgfIR|lRo6 A2p&JAgfnIR|lTHRn QJhft`x|m&g6IR|lRo> A2 Ag"p&fЃ`,IR|lTHRn QJhf `pL|N^NuNVH? n,.$. Sk" xȂ"P\I Pr2np0(f ` Sx&41"p:~fjJm(JBg0EfJSj:<Sk A4r(JBg0EfnJQBASdUHQBCSd`r BgJm(0Eg4JSj:<SkF A4 Bg&r(0Ef Ё` JQBASdUHQBCSdpLN^NuNV"n". Qp0(fp`/ Qp0// NN^NuNVH?<(n..n"Tr2 AJif*Jo*0UHf"SJn`0UH @f SJn2$Tp0R*@HmHyN-@"@&T\Kp0Ec.4r IRIg`JR~lb TJhf42tJAg$ IRIg`IR~l`F24<8<vAg2 IRIg`0H2D0H4DR~lB .L "n n $Q&$P$"Q\I R" Ҁ P\H RЈc>c8<:Fgtxv0BVA0BV@86 f J` L|N^NuNVH> n"P r‘|"$<q" Rzʁv P\HCJ gTc&4rJBggRJR|l`4rorJBglgRJRn`T8<c"4r0DfRJR|lb Sr84ro0DfRJRn L|N^NuNVH0"n /./ N"@A RЈc FXb r‘v"$<q L N^NuNVH<8$n(n &nWvƀWxȀ" e$`$// N&@C RЉJg$I`\JJg I`A`:X2Űb r“z"$<s L<(n*n &n(&b"`"W|ĆWzʀ// NL&@EJg"J`C R" ҀJg J`A RЈe2c<X4Ʋbg4c.4ذb`"<X4ưbgc 4ٲb r“|"$<s L<|N^NuNVH?<(n*n &n(&b"`"W|ĆWzʀ// NZ&@EJg"J`C R" ҀJg J`A RЈe6c<>F4Ʋbg6c04ذb`$<>F4ưbgc 4ٲb r“|"$<s L<(n*n &n&*W|ĆWxȀ// Nr&@EJg J`A R$ԀJg"J`C R" Ҁe"c60F@X4b`$0F@X4bgc 4شb r“|"$<s L<|N^NuNVH><&n*n $n&*$ԅWxȀWgJg// N$@/\//B/`/ BN*@// Nj$@IGgB$Jo,// / N rƒ < B2FApp@1/Hj/BHmN@/ N`t// N$@POJfPIGgB$Jo,// / N rƒ < B2FApp@1/Hj/BHmN r’|"$<r L<|N^NuNVH88&n$n&WxĄ"CHi/ N8$@POJfLIGg>$Jo(// / Nrƒ < B2FApp@1J g rƒt㢅r` tărFAr r’x"$<r LN^NuNVH>0&n(. $nWzʀ&$ԄJf/ / N$@`JnB/ NF$@BBj`Job// N,$@POJf \/$ \//B/NH&B$Jo,/B/ N r„$<s`DJg // N$@$B\//D//`// N$@BHj/D/HkN r’|"$<r L |N^NuIllegal bit indexNVH $n$. l Hz/ N^ Re"BHi/N&$ r‚ Rp㠁hLN^NuNVH $n$. l Hz/ N Re"BHi/N$Jg r‚ Rp㠁h` r‚ RpF@hLN^NuNVH $n$. l Hz / N Re"BHi/NZ$ r‚ RpF@hLN^NuNVH8 n 0$n&. $.Jml Hz/ N( Re&BHk/N$(rƒ*vƂ \ @Jn $<` ,<$pJn "<` ,<"f 0AP` X \"@҃Qc 0bL |N^NuNVH<0$n&. $.Jml Hz/ N^ Re&BHk/N&$(rƒ&zą \ @Jn "<` *<"pJn $<` *<$f0BF@P`&0F@X \"@0F@Qc BXbL 0$n&. $.Jml Hz/ N Re&BHk/NT$(rƒ*vƂ \ @Jn $<` ,<$pJn "<` ,<"f 0AP`X \"@ҳQc FXbL |N^NuNVH>"n . ".Jmm Qd*tĀ&xȁ Qe S&xȀ \ @Jn "<` ,<"pJn $<` ,<$f0PBV|`40Xf \Б"@0Qf `JXgp` bpL|N^NuNVH? "n$. R QdXp Q",R&$Q\J$r22(4"Jgh~m JBgfJR~lRo A4r JBgfJR~lTHRn` Qzʐ Sf"o gJRn`~m gpJR~lR(So<(S A4 Bgr g4JR~lTHRn 42ro fЁ`JRnpLN^NuNVH< n . Sk"xȀ"P\I Pe S"xȀ& 41"p:JgjJm(JBg0EfJSj:<Sk A4r(JBg0EfnJQBASdUHQBCSd`r BgJm(0Eg4JSj:<SkF A4 Bg&r(0Ef Ё` JQBASdUHQBCSdpL.O=G.gn>.O=G`TLf"p*n 05` $p*n 05(r25(t塀$xo B`0xfp*n0`p*n0r2-x顀-@xop`,xfp*n0`p*n0r2-x顀n=@-Cv *n K-Mv Ю -@r0nnftx-D *n C (@ .K-M .*n K-M .*n K-M nTH&n(.T-Dl$n .*KK-M .*KK-M .*KK-M .*KK-M~ .*KK-MzTHTKTlTJnTITLo .`>op`"f 4 `4*nl6 x頀=@p~op`zf 4 `46 x頀:op`(f4( `4 4"(.顀np2np@g:S(.޸m,Sj|UvUrSop`6f*nr6( `*nr6 *nv6r("4` (S-DJl `Jmo,zʃ(.-D(-D-Aʼo~`>f"p*n 05` $p*n 05(r25(t塀.xo B`0xfp*n0`p*n0r2-x顀-@xop`,xfp*n0`p*n0r2-x顀n=@ļm Bn`"p*n 05=@-C0nȰnftx-D *n C (@ .K-M .*n K-M .*n K-M nTH&n(.T-Dl$n .*KK-M .*KK-M .*KK-M .*KK-M .*KK-MTHTKTlTJnTITLo .`op`"f 4 `4p*nl0x頀6op`f 4 `4p0x頀=@pop`(f4( `4 4"(.顀C2.pC@g5mB@` *n 05=@`$O.gG8.L=D`Lpf64g"HRHg``KJRbB LN^NuNVH?<&I*nn.n& JZx8 (*+h,,-..//0@01223`344567H7I88K8M9H9 I999K:M<<<&<4<:.filegBitString.cc.text= 0 at line %d of `%s'. Failed assertion result.d < 1.0 && result.d >= 0 at line %d of `%s'. NVH?<"n )f@B)K"/-/K /-/N"nK/-///N`"n$Q R(= 0 at line %d of `%s'. Failed assertion result.d < 1.0 && result.d >= 0 at line %d of `%s'. NVH<8(n$T R(= 0 at line %d of `%s'. Failed assertion result.d < 1.0 && result.d >= 0 at line %d of `%s'. NVH<8(n/,/,$T R(= 0 at line %d of `%s'. Failed assertion result.d < 1.0 && result.d >= 0 at line %d of `%s'. NVH?<*n&|?|l.<$U R(/ / N//NPO/- /-//NL= 0 at line %d of `%s'. Failed assertion result.d < 1.0 && result.d >= 0 at line %d of `%s'. NVH<8(n$T R(= 0 at line %d of `%s'. Failed assertion result.d < 1.0 && result.d >= 0 at line %d of `%s'. NVH<8(n$T R(= 0 at line %d of `%s'. Failed assertion result.d < 1.0 && result.d >= 0 at line %d of `%s'. NVH?<*n/- /-B/<N//N-@-A,= 0 at line %d of `%s'. Failed assertion result.d < 1.0 && result.d >= 0 at line %d of `%s'. NVH?8(n$T R(= 0 at line %d of `%s'. Failed assertion result.d < 1.0 && result.d >= 0 at line %d of `%s'. NVH><&n|IK`R$S R(= 0 at line %d of `%s'. Failed assertion result.d < 1.0 && result.d >= 0 at line %d of `%s'. NVH?<&n~|lIK$S R(pz.filegBinomial.cc.text.data .bssLC%0LC%12LC%2x__subdf3__cmpdf2+abort5AUbmopZcall__8Binomial_RNGZdoubleMantissa__eprintf__floatsidf_RNGZsingleMantissa_vtZBinomial_vtZRandom RNG.o/ 639041752 103 100 100644 1363 ` R&P.text .data<@.bss$$/u2/jeffl/src/gcc/libg++-1.37.0/g++-include/RNG.hFailed assertion result.s < 1.0 && result.s >= 0 at line %d of `%s'. Failed assertion result.d < 1.0 && result.d >= 0 at line %d of `%s'. NVH?0&n& J9f"$= 0 at line %d of `%s'. Failed assertion result.d < 1.0 && result.d >= 0 at line %d of `%s'. NVH00$n$./ N$ %n rA0 Ёvg& <0"@ @XHo RvfA0 ЁvfS%AA0 Ё5p"* Ё5p 0j&/N%@ 0*HЪ %@ R&J/ hN L N^NuNVH<0$nzd zeA *&0`pA&**0"*A0 Ё:0E5E"* Ё:0E5Et0jo2x/</NPO j &H!HXR0jnt0jo2x/</NPO j&H!HXR0jn6j/ /N5@0j"*C0 Ё們0*H5@l :*j%CL = 0 at line %d of `%s'. Failed assertion result.d < 1.0 && result.d >= 0 at line %d of `%s'. NV/ $n/ N$4%n %n R"J/ hN $nN^NuNVH00&n"+$+JljDJljDvlvmA 'p `pA&0'A vlvmA 'p`pA&0'BE/</+ NPOR'@ /</+NR'@L N^NuNVH00&n/<Ѥ/+ NPO&E/<Ѥ/NPO D/<N/NPO$Hx//NPO'B l  /<&/+NPO&E/<&/NPOD/</NPO$Hx/N'Bl  + JnL N^NuNqGT] Yڄc{O5WK(& } a=i\$iE nr$hO~t2l*6m1냦uw2N-u!,F1+Me2l F^LV@H.filegMLCG.cc.text .data.bssLLC%0LC%12LC%2x__3RNG_vtZMLCG4lrem%lmul3G[seedTable__4MLCGllreset__4MLCGasLong__4MLCG_RNGZdoubleMantissa_RNGZsingleMantissa Sample.o/ 639041982 103 100 100644 6285 ` R&7.text XZ .data X X4 @.bss Fatal SampleStatistic error. NVH A <tJf//NPOrftJg rEtJf/./NPOrftJgr <tJf//NPOrftJgr HxNLN^NuNV 9 X# XN^NuNV/. y XNN^NuNVH?<(.*. $.B// $n*. ,.t0j(oBxv j./08/08//NJl j* 0H`XPR0j(npL|N^Nu< max : < : NVH<8(n&n v0l(oH*<x l./0(. *.t4. |v/N$@XO/B/ N 4p5@5@&JB///N(*SjB/<@//N(*B/<* Et/BGN$POE/BN$POv*n Up0(o*NYM-Mx|܎-FtI*nBB/*n/GN*n* "*n U4(BB/B/N(*n/ENXO/*n/N*PO/NXOE///N$ R*n U4(nnEGIBBHx/B/N(/BN*E* PO/INXO/NXO/N L<|N^NuNVH88 n"n 8)hf:E\Ip0(0RSg|trfpTJ4TI2 BSf`Z8)hd (H&Iv`(I&HvE\Ip0+0RSg trfTJ4TI2 BSfg `Lp0+"Ar2,DSxgJXgp`QB@SdpJg `pLN^NuNVH?<*n(n =m>,<Ub $M&L`$L&MJfp0/N-@XOr n2(Sp0*n p$ nBhUS0*ot4+n*t C  n1QUIUS4+ovzJm@t E C(4 Ђ4&ւ*| n1CUJUIUSjp0.r2J@lHn yVN .LTb &L(. `&n ( Jfp0/N-@XOr n2(Sp0+n p$ nBhUS0+ot*D4-nLt *n E C& .Ѓ @\Hf0`0D@0UJUIUS*D4-o6|vJmHt *n E C(4*BA4& ~6@ n1CUJUIUSjp0r2FJ@lHn yVN .L)*Sk "nC-It "nE"FCX& "n4>//NPO-@"ҋ4,o A4҂04, Ro .xx&@UJSSj:UMSj\(.츮g / / NhPOE RShJhn /NXOE RShJhn /N Lfp0/N&@J l . D` . $vƀJ o(A CE.8|x8-Sr`:p0+XAЍ"$@C~8|x8+Sp0-"| <=@vo BPRno*t* 4"4 n@0RŸnJ o p0` p0n0 Rp0+o" pBPR0+n LPf(Ri UShJhn /NXO*n *`*n U hoSh/ Up0/N*PO$R*n -U n\HC>**nmc 2-`2*p0ro 0Rnp*n0-opBXR*n0-n .*n&n * URh C QShJhn /NXOC QShJhn /NXOAed!C!C `/HyN LtJf//NPOxftJg xHyN$@ <$tJf//NxftJgx L<N^NuNV 9V#VN^Nuillegal length in Fix_set_default_lengthNVH0$.69PJo oHz yrN3Pp0L N^NuNV/"n QJho81|r Qp0(oXpt QBhTR Q0(n`8 Q1|r Qp0(o pt Q1|TR Q0(n$.N^NuNVN^NuNV/$./N(/N\$.N^NuFix: overflow warning NV/A <tJf//NrftJg r <$.N^NuFix: overflow error NV/A <tJf//NPOrftJg r <N$.N^Nu@&06Jdjr6<DTr$ Xh  4$$$%& '.(>)X&~$(%&&4$X)|,-./"0p10/  7 L/ h/  ,7 Z7 <&`(h/ /&/F?/CD$8ELE/// HI2JdJtKJJKLJ4K<JHJNMN///J JO\VbvVVWVVV$W,BjVpVVXVV"VHYV/`VnVVV Z,X` 8>DVrv.filegFix.cc.textP.dataP,.bss|LC%0PR/VD_Frep_0Z_Frep_m1bejLC%1LC%2$y&cerrabortLC%3rvDShumemset@LC%4__cmpdf2__adddf3__muldf3__subdf3f '8Rn 4lmulLC%5 x LC%6 LC%7  6.atofLC%8LC%9)6sprintfI\dWSLC%10"LC%11)LC%120LC%137LC%14>Fcout+ATjRLC%15h\dLC%16LC%17-Fix_default_lengthFix_default_print_widthFix_overflow_handlerFix_overflow_saturate__FRP5_Frep_Frep_quotient_bumpdefault_Fix_error_handler__FPCcsputs__9streambufPCcdefault_Fix_range_error_handler__FPCcFix_error_handlerFix_range_error_handlerset_Fix_error_handler__FPFPCc_vset_Fix_range_error_handler__FPFPCc_verror__3FixPCcrange_error__3FixPCcnew_Fix__FUs__builtin_newnew_Fix__FUsP5_Frepnew_Fix__FUsd__fixdfsi__floatsidfvalue__FR3Fixmantissa__FR3FixIcopy_long__FP6IntRepllshift__FPC6IntReplP6IntRepadd__FPC6IntRepilP6IntRep__builtin_deleteIcopy__FP6IntRepPC6IntRepadd__FPC6IntRepiT0iP6IntRepcompare__FP5_FrepT0add__FP5_FrepN20subtract__FP5_FrepN20multiply__FP5_FrepN20negate__FP5_FrepT0multiply__FP5_FrepiT0divide__FP5_FrepN30shift__FP5_FrepiT0atoF__FPCciFtoa__FR3Fixi_libgxx_fmtqalloc__9AllocRingiopZassign_trunc_mod__3FixiopZarshift__FR7istreamR3FixopZarshift__7istreamR10whitespace_libgxx_io_obnewchunk__7Obstackiget__7istreamRcfinish__7Obstackerror__7istream_free__7ObstackPvshow__FR3FixopZalshift__7ostreamUsopZalshift__7ostreamsItoa__FPC6IntRepiiopZalshift__7ostreamdset_overflow_handler__FPFRP5_Frep_vFix_set_default_length__FiFix_overflow_wrap__FRP5_FrepFix_overflow_warning_saturate__FRP5_FrepFix_overflow_warning__FRP5_FrepFix_overflow_error__FRP5_Frep Fix16.o/ 639042487 103 100 100644 4727 ` R& 6.textH@ .dataHH d@.bssXXNVJ g /.NN^NuNVH8(.$. &.B/0&I"n n JQ\xȀg 2H`2HD*|JP\vƀg4`4DB0Bn&f =|`=|Hn/ NB`@4B/ /NPO=@/ /N"0lR@@0@nRngDn0n=H6 L |N^NuNVH> $I"n n J\zʀg"`"DJ\xȀg&`&Db*f-|` -|Hn/ N`@Bt d .|-@` ,.-FSJnԸgD .-@$ L|N^NuNV/. yHNN^NuNV/. yLNN^NuNV/. yPNN^NuNV/. yTNN^NuNV 9H#HN^NuNV 9L#LN^NuNV/.N/. NN^NuNV 9P#PN^NuNV 9T#TN^NuNV/.N/. NN^NuNV nJPo 0<`0<0N^NuNVN^Nuwarning: Fix16 result out of range NV/A <tJf//NrftJg r <$.N^NuNV/A <tJf//NPOrftJg r </.N$.N^Nuerror: Fix16 result out of range NV/A <jtJf//NPOrftJg r <N$.N^NuNVN^NuNV nJo <` < N^Nuwarning: Fix32 result out of range NV/A < tJf//NrftJg r <$.N^NuNV/A < tJf//NPOrftJg r </.N $.N^Nuerror: Fix32 result out of range NV/A <tJf//NPOrftJg r <N$.N^Nu|0 < b     X      6D>FT\+,+++"6,P+V++,++08+>R,j+p++,+++,0+6+<0HLPT.filegFix16.cc.textH@.dataH.bssX_Z_Fix32__cmpdf2%__muldf3__adddf3__subdf3;E6UkRlmulldivlremHLPT9|Vs0  8,NSdzLC%0cerrLC%1jabortLC%2 |LC%3__builtin_deleteassign__5Fix16drange_error__5Fix16Rs__fixdfsiassign__5Fix32drange_error__5Fix32RlopZmult__FR5Fix32T0opZtrunc_div__FR5Fix16T0opZtrunc_div__FR5Fix32T0overflow__5Fix16RsFix16_overflow_handleroverflow__5Fix32RlFix32_overflow_handlerFix16_range_error_handlerFix32_range_error_handlerFix16_overflow_saturate__FRsFix32_overflow_saturate__FRlFix16_warning__FRsFix32_warning__FRlset_Fix16_overflow_handler__FPFRs_vset_Fix32_overflow_handler__FPFRl_vset_overflow_handler__FPFRs_vPFRl_vset_Fix16_range_error_handler__FPFRs_vset_Fix32_range_error_handler__FPFRl_vset_range_error_handler__FPFRs_vPFRl_vFix16_ignore__FRssputs__9streambufPCcFix16_overflow_warning_saturate__FRsFix16_abort__FRsFix32_ignore__FRlFix32_overflow_warning_saturate__FRlFix32_abort__FRl Fix24.o/ 639042664 103 100 100644 6660 ` R&hO.text  O .data   @.bss NVJ g /.NN^NuNVH< (.$. &.B/ $I"n n J\zʀg"`"DJ\xȀg&`&Db*f-|` -|Hn/ Nf`HBt d .|-@` ,.-FSJngD,.F$ L|N^NuNVH0 $I"n n )"(Ё"Ґg-A-@ $Jl Hn/ N$.&.$%C L N^NuNVH8 $I"n n )"($g-B-@ "DJlJg Hn/ N$&.(.$%D LN^NuNVH?8(I&n". \zʀg(`(D c:Jg-yJ-yN`-yR-yVHn/ N`x +E//NPO& +|//NPO$//N"ց-CЂ-@Jf"D".F .Jm-A,...()G LN^NuNVH< I"n$. xvJmDzm( r*)"A*ځ&*)(`z/mpЂ*)& !D L?C`?>AA x < f    ".|   ( T` $08X .6DLrz 2  "3 :2 @2 T2 Z n3 2 2 2  3 2 2 7 0 6 @ F 2  3 2 2 2  3 2 2 D2 J ^3 x2 ~2 7    .filegFix24.cc.text O.data .bss _Z_Fix48__cmpdf2%__muldf3__adddf3;ELC%0JLC%1RQZa__negdf2__subdf3lmul4l&L<O f }     x!(E>qTl"LC%2cerr4I LLC%3 n abort LC%4 T LC%5  <      # - Fix48_fs 7 C O Y c m w  Fix24_fs __builtin_deleteassign__5Fix24drange_error__5Fix24Rl__fixdfsi__floatsidfassign__5Fix48drange_error__5Fix48R8twolongs__fixunsdfsiopZmult__FR5Fix24T0opZtrunc_div__FR5Fix24T0opZplus__FR5Fix48T0overflow__5Fix48R8twolongsopZminus__FR5Fix48T0opZmult__FR5Fix48iopZalshift__FR5Fix48iopZarshift__FR5Fix48ioverflow__5Fix24RlFix24_overflow_handlerFix48_overflow_handlerFix24_range_error_handlerFix48_range_error_handlerFix24_overflow_saturate__FRlFix48_overflow_saturate__FR8twolongsFix24_warning__FRlFix48_warning__FR8twolongsset_Fix24_overflow_handler__FPFRl_vset_Fix48_overflow_handler__FPFR8twolongs_vset_overflow_handler__FPFRl_vPFR8twolongs_vset_Fix24_range_error_handler__FPFRl_vset_Fix48_range_error_handler__FPFR8twolongs_vset_range_error_handler__FPFRl_vPFR8twolongs_vFix24_ignore__FRlsputs__9streambufPCcFix24_overflow_warning_saturate__FRlFix24_abort__FRlFix48_ignore__FR8twolongsFix48_overflow_warning_saturate__FR8twolongsFix48_abort__FR8twolongsFix48_m_minFix48_m_maxFix48_lsbFix48_msbFix48_div_lFix48_div_uFix48_minFix48_maxFix24_m_minFix24_m_maxFix24_lsbFix24_msbFix24_minFix24_maxFix24_divFix24_multGetOpt.o/ 639042722 103 100 100644 2427 ` R&".text$3 .data@.bss_POSIX_OPTION_ORDERNV/ $n nr%A%n %n%H%A##BB -fr`HzNJg B` r# $nN^NuNVH<8$n&n $9 Rz& 9/Hs/IN 9"9(*/HsHsN 9Ъ//HsN *ѹ#L&9g0#`$ j * p -f J(fR&* m#&* gzHz j */0NPOJfZR&9g &9g/*/ NPO`&9f ## %j &* f&9g6%y`* j * p -f J(f*Jfp`^ j *$Rp`F j *&0R# yR *HH//N"@PO yJfRg :fTJgF o ~oHH/ j/Hzo`HH/ j/HzHyNp?` ):f ):f yJg$`bB`` yJg$`J&* f0Jg HH/ j/Hz/HyN<?` j *$RBHHL N^Nu> D J d p|         $ ,        T x          $\ b j ~  & ^d .filegGetOpt.cc.text3.data.bssLC%0(=getenvN_memcpyLC%1:LC%2=LC%3jLC%4tstrcmpstrchr_iobfprintf__6GetOptiPPcPc_GetOptZlast_nonopt_GetOptZfirst_nonopt_GetOptZnextchar_GetOptZorderingexchange__6GetOptPPcopZcall__6GetOpt EH.o/ 639042804 103 100 100644 1107 ` R&d.text .dataDZ@.bss88unhandled exception, aborting... NVH $nf\HyNXOJgTA <tJf//NPOrftJg r <N$4#4 LN^NuNV n#4J g /NN^NuNVBHyNN^NuNVHyN6N^NuNq0:@ N Th  4.filegEH.cc.text.dataD.bss8EHS4LC%0"setjmpcerr/abortDXixexceptionHandlerStack__16ExceptionHandlersputs__9streambufPCc_Z_ExceptionHandler__builtin_delete_GLOBAL_ZDZEHS_GLOBAL_ZIZEHS EH2.o/ 639042827 103 100 100644 372 ` R& .text .data@.bssNVNN^NuNq .filegEH2.c.text.data.bssabort__unhandled_exceptionxyzzy.o/ 639042863 103 100 100644 435 ` R&/ .text .data@.bssNVN^NuNV <N^NuNq.filegxyzzy.cc.text.data.bss%;__1xyzzy___GLOBAL_ZDZ__1xyzzy___GLOBAL_ZIZ__1xyzzy__ gnulib3.o/ 639042893 103 100 100644 952 ` R&M.texth .data@.bssNVA##HyN"N^NuNVNNN/.NN^NuNVH0 "< 9vo$A$ԁ ZNnL N^NuNVJgR` 9 y hNSj y #g y#JfN^NuNq    .8JP~         .fileggnulib3.c.text.data.bss__main__dli__dlp@exit$.x_cleanup_exitBP__DTOR_LIST____1xyzzy____do_global_init__do_global_cleanup__CTOR_LIST__new.o/ 639042917 103 100 100644 284 ` R&e.text .data@.bss.filegnew.cc.text.data.bssdelete.o/ 639042935 103 100 100644 284 ` R&v.text .data@.bss.filegdelete.cc.text.data.bssmalloc.o/ 639042949 103 100 100644 284 ` R&.text .data@.bss.filegmalloc.c.text.data.bsschr.o/ 639042999 103 100 100644 474 ` R& .textP .dataPP@.bssPPNVH 0. $n 6|HrHyN" A Jo SJnB L N^NuNq  .filegchr.cc.textP.dataP.bssPchr__Fci$_libgxx_fmtqalloc__9AllocRingidtoa.o/ 639043076 103 100 100644 3352 ` R& R.text  - .data  @.bss  NV H?<-n -n n3..G2K0-M.B*b-E*"EBBB/./. NJ]z-@&g/./. NPO-@ -A o.<zf-|A.B"`/B/<@$N-@-A" /."/.B//<C-/0&.$. &n| f E ` /N/Hx!NPO @EXO/ HyN @E* B"POJf <0`B(Jg://NPO//NPO&  o W`0Jf S`< "Rn L |N^NuNVH?<(n*n *.&nx f E` /N/HxANPO @EXO/ HyN @E. B"BPOBB/// / Nxf <0`BB/// / Nxon<-/ / NPO(@*A`Vr lF/// / Nr lF/// / N(@*A  o W`0BB/// / NxfJg S`< "Rn L J \ b .filegitoa.cc.text.data.bsslg__FUlldivulremuldiv/;__cmpdi2__negdi2__moddi3__divdi3FR\fhex__Fli(oct__Fli@dec__FliXppzitoa__Flii_libgxx_fmtqalloc__9AllocRingiitoa__FUliiitoa__Fxiiitoa__FUxii__ucmpdi2__umoddi3__udivdi3hex__FUlioct__FUlidec__FUlilg.o/ 639043612 103 100 100644 342 ` R& .text( .data((@.bss((NV/ .r`Rte $.N^NuNq.fileglg.cc.text(.data(.bss(lg__FUllibgxx_fmtq.o/ 639043716 103 100 100644 566 ` R& .text0 .data00 @.bss<<NVBHy0NN^NuNVHxHy0NN^NuNq  & .fileglibgxx_fmtq.cc.text0.data0 .bss<0)6N\_libgxx_fmtq_GLOBAL_ZDZ_libgxx_fmtq_Z_AllocRing_GLOBAL_ZIZ_libgxx_fmtq__9AllocRingilibgxx_io.o/ 639043818 103 100 100644 589 ` R& .text4 .data44@.bssLLNVBHy4NN^NuNVHxHxHy4NN^NuNq $* .fileglibgxx_io.cc.text4.data4.bssL4+=Vc_libgxx_io_ob_GLOBAL_ZDZ_libgxx_io_ob_free__7ObstackPv_GLOBAL_ZIZ_libgxx_io_ob__7Obstackii pow.o/ 639043926 103 100 100644 834 ` R& VF.textt .datatt@.bssttNVH>&.(. $.f6BB//NJlg <B`