home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / libgpp.i04 (.txt) < prev    next >
GNU Info File  |  1993-06-12  |  53KB  |  1,103 lines

  1. This is Info file libgpp, produced by Makeinfo-1.47 from the input file
  2. libgpp.tex.
  3. START-INFO-DIR-ENTRY
  4. * Libg++: (libg++).        The g++ library.
  5. END-INFO-DIR-ENTRY
  6.    This file documents the features and implementation of The GNU C++
  7. library
  8.    Copyright (C) 1988, 1991, 1992 Free Software Foundation, Inc.
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided also
  14. that the section entitled "GNU Library General Public License" is
  15. included exactly as in the original, and provided that the entire
  16. resulting derived work is distributed under the terms of a permission
  17. notice identical to this one.
  18.    Permission is granted to copy and distribute translations of this
  19. manual into another language, under the above conditions for modified
  20. versions, except that the section entitled "GNU Library General Public
  21. License" and this permission notice may be included in translations
  22. approved by the Free Software Foundation instead of in the original
  23. English.
  24. File: libgpp,  Node: Random,  Next: Data,  Prev: Bit,  Up: Top
  25. Random Number Generators and related classes
  26. ********************************************
  27.    The two classes `RNG' and `Random' are used together to generate a
  28. variety of random number distributions.  A distinction must be made
  29. between *random number generators*, implemented by class `RNG', and
  30. *random number distributions*.  A random number generator produces a
  31. series of randomly ordered bits.  These bits can be used directly, or
  32. cast to other representations, such as a floating point value.  A
  33. random number generator should produce a *uniform* distribution.  A
  34. random number distribution, on the other hand, uses the randomly
  35. generated bits of a generator to produce numbers from a distribution
  36. with specific properties.  Each instance of `Random' uses an instance
  37. of class `RNG' to provide the raw, uniform distribution used to produce
  38. the specific distribution.  Several instances of `Random' classes can
  39. share the same instance of `RNG', or each instance can use its own copy.
  40.    Random distributions are constructed from members of class `RNG',
  41. the actual random number generators.  The `RNG' class contains no data;
  42. it only serves to define the interface to random number generators. 
  43. The `RNG::asLong' member returns an unsigned long (typically 32 bits)
  44. of random bits.  Applications that require a number of random bits can
  45. use this directly.  More often, these random bits are transformed to a
  46. uniform random number:
  47.          //
  48.          // Return random bits converted to either a float or a double
  49.          //
  50.          float asFloat();
  51.          double asDouble();
  52.      };
  53. using either `asFloat' or `asDouble'.  It is intended that `asFloat'
  54. and `asDouble' return differing precisions; typically, `asDouble' will
  55. draw two random longwords and transform them into a legal `double',
  56. while `asFloat' will draw a single longword and transform it into a
  57. legal `float'.  These members are used by subclasses of the `Random'
  58. class to implement a variety of random number distributions.
  59.    Class `ACG' is a variant of a Linear Congruential Generator
  60. (Algorithm M) described in Knuth, *Art of Computer Programming, Vol
  61. III*.  This result is permuted with a Fibonacci Additive Congruential
  62. Generator to get good independence between samples.  This is a very high
  63. quality random number generator, although it requires a fair amount of
  64. memory for each instance of the generator.
  65.    The `ACG::ACG' constructor takes two parameters: the seed and the
  66. size.  The seed is any number to be used as an initial seed. The
  67. performance of the generator depends on having a distribution of bits
  68. through the seed.  If you choose a number in the range of 0 to 31, a
  69. seed with more bits is chosen. Other values are deterministically
  70. modified to give a better distribution of bits.  This provides a good
  71. random number generator while still allowing a sequence to be repeated
  72. given the same initial seed.
  73.    The `size' parameter determines the size of two tables used in the
  74. generator. The first table is used in the Additive Generator; see the
  75. algorithm in Knuth for more information. In general, this table is
  76. `size' longwords long. The default value, used in the algorithm in
  77. Knuth, gives a table of 220 bytes. The table size affects the period of
  78. the generators; smaller values give shorter periods and larger tables
  79. give longer periods. The smallest table size is 7 longwords, and the
  80. longest is 98 longwords. The `size' parameter also determines the size
  81. of the table used for the Linear Congruential Generator. This value is
  82. chosen implicitly based on the size of the Additive Congruential
  83. Generator table. It is two powers of two larger than the power of two
  84. that is larger than `size'.  For example, if `size' is 7, the ACG table
  85. is 7 longwords and the LCG table is 128 longwords. Thus, the default
  86. size (55) requires 55 + 256 longwords, or 1244 bytes. The largest table
  87. requires 2440 bytes and the smallest table requires 100 bytes. 
  88. Applications that require a large number of generators or applications
  89. that aren't so fussy about the quality of the generator may elect to
  90. use the `MLCG' generator.
  91.    The `MLCG' class implements a *Multiplicative Linear Congruential
  92. Generator*. In particular, it is an implementation of the double MLCG
  93. described in *"Efficient and Portable Combined Random Number
  94. Generators"* by Pierre L'Ecuyer, appearing in *Communications of the
  95. ACM, Vol. 31. No. 6*. This generator has a fairly long period, and has
  96. been statistically analyzed to show that it gives good inter-sample
  97. independence.
  98.    The `MLCG::MLCG' constructor has two parameters, both of which are
  99. seeds for the generator. As in the `MLCG' generator, both seeds are
  100. modified to give a "better" distribution of seed digits. Thus, you can
  101. safely use values such as `0' or `1' for the seeds. The `MLCG'
  102. generator used much less state than the `ACG' generator; only two
  103. longwords (8 bytes) are needed for each generator.
  104. Random
  105. ======
  106.    A random number generator may be declared by first declaring a `RNG'
  107. and then a `Random'. For example, `ACG gen(10, 20); NegativeExpntl rnd
  108. (1.0, &gen);' declares an additive congruential generator with seed 10
  109. and table size 20, that is used to generate exponentially distributed
  110. values with mean of 1.0.
  111.    The virtual member `Random::operator()' is the common way of
  112. extracting a random number from a particular distribution.  The base
  113. class, `Random' does not implement `operator()'. This is performed by
  114. each of the subclasses. Thus, given the above declaration of `rnd', new
  115. random values may be obtained via, for example, `double next_exp_rand =
  116. rnd();' Currently, the following subclasses are provided.
  117. Binomial
  118. ========
  119.    The binomial distribution models successfully drawing items from a
  120. pool.  The first parameter to the constructor, `n', is the number of
  121. items in the pool, and the second parameter, `u', is the probability of
  122. each item being successfully drawn.  The member `asDouble' returns the
  123. number of samples drawn from the pool.  Although it is not checked, it
  124. is assumed that `n>0' and `0 <= u <= 1'.  The remaining members allow
  125. you to read and set the parameters.
  126. Erlang
  127. ======
  128.    The `Erlang' class implements an Erlang distribution with mean
  129. `mean' and variance `variance'.
  130. Geometric
  131. =========
  132.    The `Geometric' class implements a discrete geometric distribution. 
  133. The first parameter to the constructor, `mean', is the mean of the
  134. distribution.  Although it is not checked, it is assumed that `0 <=
  135. mean <= 1'. `Geometric()' returns the number of uniform random samples
  136. that were drawn before the sample was larger than `mean'. This quantity
  137. is always greater than zero.
  138. HyperGeometric
  139. ==============
  140.    The `HyperGeometric' class implements the hypergeometric
  141. distribution.  The first parameter to the constructor, `mean', is the
  142. mean and the second, `variance', is the variance.  The remaining
  143. members allow you to inspect and change the mean and variance.
  144. NegativeExpntl
  145. ==============
  146.    The `NegativeExpntl' class implements the negative exponential
  147. distribution.  The first parameter to the constructor is the mean.  The
  148. remaining members allow you to inspect and change the mean.
  149. Normal
  150. ======
  151.    The `Normal'class implements the normal distribution.  The first
  152. parameter to the constructor, `mean', is the mean and the second,
  153. `variance', is the variance.  The remaining members allow you to
  154. inspect and change the mean and variance. The `LogNormal' class is a
  155. subclass of `Normal'.
  156. LogNormal
  157. =========
  158.    The `LogNormal'class implements the logarithmic normal distribution.
  159.  The first parameter to the constructor, `mean', is the mean and the
  160. second, `variance', is the variance.  The remaining members allow you
  161. to inspect and change the mean and variance.  The `LogNormal' class is
  162. a subclass of `Normal'.
  163. Poisson
  164. =======
  165.    The `Poisson' class implements the poisson distribution. The first
  166. parameter to the constructor is the mean.  The remaining members allow
  167. you to inspect and change the mean.
  168. DiscreteUniform
  169. ===============
  170.    The `DiscreteUniform' class implements a uniform random variable over
  171. the closed interval ranging from `[low..high]'.  The first parameter to
  172. the constructor is `low', and the second is `high', although the order
  173. of these may be reversed.  The remaining members allow you to inspect
  174. and change `low' and `high'.
  175. Uniform
  176. =======
  177.    The `Uniform' class implements a uniform random variable over the
  178. open interval ranging from `[low..high)'.  The first parameter to the
  179. constructor is `low', and the second is `high', although the order of
  180. these may be reversed.  The remaining members allow you to inspect and
  181. change `low' and `high'.
  182. Weibull
  183. =======
  184.    The `Weibull' class implements a weibull distribution with
  185. parameters `alpha' and `beta'.  The first parameter to the class
  186. constructor is `alpha', and the second parameter is `beta'.  The
  187. remaining members allow you to inspect and change `alpha' and `beta'.
  188. RandomInteger
  189. =============
  190.    The `RandomInteger' class is *not* a subclass of Random, but a
  191. stand-alone integer-oriented class that is dependent on the RNG
  192. classes. RandomInteger returns random integers uniformly from the
  193. closed interval `[low..high]'.  The first parameter to the constructor
  194. is `low', and the second is `high', although both are optional.  The
  195. last argument is always a generator. Additional members allow you to
  196. inspect and change `low' and `high'.  Random integers are generated
  197. using `asInt()' or `asLong()'.  Operator syntax (`()') is also
  198. available as a shorthand for `asLong()'.  Because `RandomInteger' is
  199. often used in simulations for which uniform random integers are desired
  200. over a variety of ranges, `asLong()' and `asInt' have `high' as an
  201. optional argument.  Using this optional argument produces a single
  202. value from the new range, but does not change the default range.
  203. File: libgpp,  Node: Data,  Next: Curses,  Prev: Random,  Up: Top
  204. Data Collection
  205. ***************
  206.    Libg++ currently provides two classes for *data collection* and
  207. analysis of the collected data.
  208. SampleStatistic
  209. ===============
  210.    Class `SampleStatistic' provides a means of accumulating samples of
  211. `double' values and providing common sample statistics.
  212.    Assume declaration of `double x'.
  213. `SampleStatistic a;'
  214.      declares and initializes a.
  215. `a.reset();'
  216.      re-initializes a.
  217. `a += x;'
  218.      adds sample x.
  219. `int n = a.samples();'
  220.      returns the number of samples.
  221. `x = a.mean;'
  222.      returns the means of the samples.
  223. `x = a.var()'
  224.      returns the sample variance of the samples.
  225. `x = a.stdDev()'
  226.      returns the sample standard deviation of the samples.
  227. `x = a.min()'
  228.      returns the minimum encountered sample.
  229. `x = a.max()'
  230.      returns the maximum encountered sample.
  231. `x = a.confidence(int p)'
  232.      returns the p-percent (0 <= p < 100) confidence interval.
  233. `x = a.confidence(double p)'
  234.      returns the p-probability (0 <= p < 1) confidence interval.
  235. SampleHistogram
  236. ===============
  237.    Class `SampleHistogram' is a derived class of `SampleStatistic' that
  238. supports collection and display of samples in bucketed intervals. It
  239. supports the following in addition to `SampleStatisic' operations.
  240. `SampleHistogram h(double lo, double hi, double width);'
  241.      declares and initializes h to have buckets of size width from lo
  242.      to hi. If the optional argument width is not specified, 10 buckets
  243.      are created. The first bucket and also holds samples less than lo,
  244.      and the last one holds samples greater than hi.
  245. `int n = h.similarSamples(x)'
  246.      returns the number of samples in the same bucket as x.
  247. `int n = h.inBucket(int i)'
  248.      returns the number of samples in  bucket i.
  249. `int b = h.buckets()'
  250.      returns the number of buckets.
  251. `h.printBuckets(ostream s)'
  252.      prints bucket counts on ostream s.
  253. `double bound = h.bucketThreshold(int i)'
  254.      returns the upper bound of bucket i.
  255. File: libgpp,  Node: Curses,  Next: List,  Prev: Data,  Up: Top
  256. Curses-based classes
  257. ********************
  258.    The `CursesWindow' class is a repackaging of standard curses library
  259. features into a class. It relies on `curses.h'.
  260.    The supplied `curses.h' is a fairly conservative declaration of
  261. curses library features, and does not include features like "screen" or
  262. X-window support. It is, for the most part, an adaptation, rather than
  263. an improvement of C-based `curses.h' files. The only substantive
  264. changes are the declarations of many functions as inline functions
  265. rather than macros, which was done solely to allow overloading.
  266.    The `CursesWindow' class encapsulates curses window functions within
  267. a class. Only those functions that control windows are included:
  268. Terminal control functions and macros like `cbreak' are not part of the
  269. class.  All `CursesWindows' member functions have names identical to
  270. the corresponding curses library functions, except that the "w" prefix
  271. is generally dropped. Descriptions of these functions may be found in
  272. your local curses library documentation.
  273.    A `CursesWindow' may be declared via
  274. `CursesWindow w(WINDOW* win)'
  275.      attaches w to the existing WINDOW* win. This is constructor is
  276.      normally used only in the following special case.
  277. `CursesWindow w(stdscr)'
  278.      attaches w to the default curses library standard screen window.
  279. `CursesWindow w(int lines, int cols, int begin_y, int begin_x)'
  280.      attaches to an allocated curses window with the indicated size and
  281.      screen position.
  282. `CursesWindow sub(CursesWindow& w,int l,int c,int by,int bx,char ar='a')'
  283.      attaches to a subwindow of w created via the curses `subwin'
  284.      command. If ar is sent as `r', the origin (by, bx) is relative to
  285.      the parent window, else it is absolute.
  286.    The class maintains a static counter that is used in order to
  287. automatically call the curses library `initscr' and `endscr' functions
  288. at the proper times. These need not, and should not be called
  289. "manually".
  290.    `CursesWindow's maintain a tree of their subwindows. Upon
  291. destruction of a `CursesWindow', all of their subwindows are also
  292. invalidated if they had not previously been destroyed.
  293.    It is possible to traverse trees of subwindows via the following
  294. member functions
  295. `CursesWindow* w.parent()'
  296.      returns a pointer to the parent of the subwindow, or 0 if there is
  297.      none.
  298. `CursesWindow* w.child()'
  299.      returns the first child subwindow of the window, or 0 if there is
  300.      none.
  301. `CursesWindow* w.sibling()'
  302.      returns the next sibling of the subwindow, or 0 if there is none.
  303.    For example, to call some function `visit' for all subwindows of a
  304. window, you could write
  305.      void traverse(CursesWindow& w)
  306.      {
  307.        visit(w);
  308.        if (w.child() != 0) traverse(*w.child);
  309.        if (w.sibling() != 0) traverse(*w.sibling);
  310.      }
  311. File: libgpp,  Node: List,  Next: LinkList,  Prev: Curses,  Up: Top
  312. List classes
  313. ************
  314.    The files `g++-include/List.hP' and `g++-include/List.ccP' provide
  315. pseudo-generic Lisp-type List classes.  These lists are homogeneous
  316. lists, more similar to lists in statically typed functional languages
  317. like ML than Lisp, but support operations very similar to those found
  318. in Lisp. Any particular kind of list class may be generated via the
  319. `genclass' shell command. However, the implementation assumes that the
  320. base class supports an equality operator `=='.  All equality tests use
  321. the `==' operator, and are thus equivalent to the use of `equal', not
  322. `eq' in Lisp.
  323.    All list nodes are created dynamically, and managed via reference
  324. counts. `List' variables are actually pointers to these list nodes.
  325. Lists may also be traversed via Pixes, as described in the section
  326. describing Pixes. *Note Pix::
  327.    Supported operations are mirrored closely after those in Lisp.
  328. Generally, operations with functional forms are constructive,
  329. functional operations, while member forms (often with the same name)
  330. are sometimes procedural, possibly destructive operations.
  331.    As with Lisp, destructive operations are supported. Programmers are
  332. allowed to change head and tail fields in any fashion, creating
  333. circular structures and the like. However, again as with Lisp, some
  334. operations implicitly assume that they are operating on pure lists, and
  335. may enter infinite loops when presented with improper lists. Also, the
  336. reference-counting storage management facility may fail to reclaim
  337. unused circularly-linked nodes.
  338.    Several Lisp-like higher order functions are supported (e.g., `map').
  339. Typedef declarations for the required functional forms are provided int
  340. the `.h' file.
  341.    For purposes of illustration, assume the specification of class
  342. `intList'.  Common Lisp versions of supported operations are shown in
  343. brackets for comparison purposes.
  344. Constructors and assignment
  345. ===========================
  346. `intList a;           [ (setq a nil) ]'
  347.      Declares a to be a nil intList.
  348. `intList b(2);        [ (setq b (cons 2 nil)) ]'
  349.      Declares b to be an intList with a head value of 2, and a nil tail.
  350. `intList c(3, b);     [ (setq c (cons 3 b)) ]'
  351.      Declares c to be an intList with a head value of 3, and b as its
  352.      tail.
  353. `b = a;               [ (setq b a) ]'
  354.      Sets b to be the same list as a.
  355.    Assume the declarations of intLists a, b, and c in the following.
  356. *Note Pix::.
  357. List status
  358. ===========
  359. `a.null(); OR !a;      [ (null a) ]'
  360.      returns true if a is null.
  361. `a.valid();            [ (listp a) ]'
  362.      returns true if a is non-null. Inside a conditional test, the
  363.      `void*' coercion may also be used as in `if (a) ...'.
  364. `intList();            [ nil ]'
  365.      intList() may be used to null terminate a list, as in `intList
  366.      f(int x) {if (x == 0) return intList(); ... } '.
  367. `a.length();           [ (length a) ]'
  368.      returns the length of a.
  369. `a.list_length();      [ (list-length a) ]'
  370.      returns the length of a, or -1 if a is circular.
  371. heads and tails
  372. ===============
  373. `a.get(); OR a.head()  [ (car a) ]'
  374.      returns a reference to the head field.
  375. `a[2];                 [ (elt a 2) ]'
  376.      returns a reference to the second (counting from zero) head field.
  377. `a.tail();             [ (cdr a) ]'
  378.      returns the intList that is the tail of a.
  379. `a.last();             [ (last a) ]'
  380.      returns the intList that is the last node of a.
  381. `a.nth(2);             [ (nth a 2) ]'
  382.      returns the intList that is the nth node of a.
  383. `a.set_tail(b);        [ (rplacd a b) ]'
  384.      sets a's tail to b.
  385. `a.push(2);            [ (push 2 a) ]'
  386.      equivalent to a = intList(2, a);
  387. `int x = a.pop()       [ (setq x (car a)) (pop a) ]'
  388.      returns the head of a, also setting a to its tail.
  389. Constructive operations
  390. =======================
  391. `b = copy(a);          [ (setq b (copy-seq a)) ]'
  392.      sets b to a copy of a.
  393. `b = reverse(a);       [ (setq b (reverse a)) ]'
  394.      Sets b to a reversed copy of a.
  395. `c = concat(a, b);     [ (setq c (concat a b)) ]'
  396.      Sets c to a concatenated copy of a and b.
  397. `c = append(a, b);     [ (setq c (append a b)) ]'
  398.      Sets c to a concatenated copy of a and b. All nodes of a are
  399.      copied, with the last node pointing to b.
  400. `b = map(f, a);        [ (setq b (mapcar f a)) ]'
  401.      Sets b to a new list created by applying function f to each node
  402.      of a.
  403. `c = combine(f, a, b);'
  404.      Sets c to a new list created by applying function f to successive
  405.      pairs of a and b. The resulting list has length the shorter of a
  406.      and b.
  407. `b = remove(x, a);     [ (setq b (remove x a)) ]'
  408.      Sets b to a copy of a, omitting all occurrences of x.
  409. `b = remove(f, a);     [ (setq b (remove-if f a)) ]'
  410.      Sets b to a copy of a, omitting values causing function f to
  411.      return true.
  412. `b = select(f, a);     [ (setq b (remove-if-not f a)) ]'
  413.      Sets b to a copy of a, omitting values causing function f to
  414.      return false.
  415. `c = merge(a, b, f);   [ (setq c (merge a b f)) ]'
  416.      Sets c to a list containing the ordered elements (using the
  417.      comparison function f) of the sorted lists a and b.
  418. Destructive operations
  419. ======================
  420. `a.append(b);          [ (rplacd (last a) b) ]'
  421.      appends b to the end of a. No new nodes are constructed.
  422. `a.prepend(b);         [ (setq a (append b a)) ]'
  423.      prepends b to the beginning of a.
  424. `a.del(x);             [ (delete x a) ]'
  425.      deletes all nodes with value x from a.
  426. `a.del(f);             [ (delete-if f a) ]'
  427.      deletes all nodes causing function f to return true.
  428. `a.select(f);          [ (delete-if-not f a) ]'
  429.      deletes all nodes causing function f to return false.
  430. `a.reverse();          [ (nreverse a) ]'
  431.      reverses a in-place.
  432. `a.sort(f);            [ (sort a f) ]'
  433.      sorts a in-place using ordering (comparison) function f.
  434. `a.apply(f);           [ (mapc f a) ]'
  435.      Applies void function f (int x) to each element of a.
  436. `a.subst(int old, int repl); [ (nsubst repl old a) ]'
  437.      substitutes repl for each occurrence of old in a. Note the
  438.      different argument order than the Lisp version.
  439. Other operations
  440. ================
  441. `a.find(int x);       [ (find x a) ]'
  442.      returns the intList at the first occurrence of x.
  443. `a.find(b);           [ (find b a) ]'
  444.      returns the intList at the first occurrence of sublist b.
  445. `a.contains(int x);    [ (member x a) ]'
  446.      returns true if a contains x.
  447. `a.contains(b);        [ (member b a) ]'
  448.      returns true if a contains sublist b.
  449. `a.position(int x);    [ (position x a) ]'
  450.      returns the zero-based index of x in a, or -1 if x does not occur.
  451. `int x = a.reduce(f, int base); [ (reduce f a :initial-value base) ]'
  452.      Accumulates the result of applying int function f(int, int) to
  453.      successive elements of a, starting with base.
  454. File: libgpp,  Node: LinkList,  Next: Vector,  Prev: List,  Up: Top
  455. Linked Lists
  456. ************
  457.    SLLists provide pseudo-generic singly linked lists.  DLLists provide
  458. doubly linked lists.  The lists are designed for the simple maintenance
  459. of elements in a linked structure, and do not provide the more extensive
  460. operations (or node-sharing) of class `List'. They behave similarly to
  461. the `slist' and similar classes described by Stroustrup.
  462.    All list nodes are created dynamically. Assignment is performed via
  463. copying.
  464.    Class `DLList' supports all `SLList' operations, plus additional
  465. operations described below.
  466.    For purposes of illustration, assume the specification of class
  467. `intSLList'. In addition to the operations listed here, SLLists support
  468. traversal via Pixes. *Note Pix::
  469. `intSLList a;'
  470.      Declares a to be an empty list.
  471. `intSLList b = a;'
  472.      Sets b to an element-by-element copy of a.
  473. `a.empty()'
  474.      returns true if a contains no elements
  475. `a.length();'
  476.      returns the number of elements in a.
  477. `a.prepend(x);'
  478.      places x at the front of the list.
  479. `a.append(x);'
  480.      places x at the end of the list.
  481. `a.join(b)'
  482.      places all nodes from b to the end of a, simultaneously destroying
  483.      b.
  484. `x = a.front()'
  485.      returns a reference to the item stored at the head of the list, or
  486.      triggers an error if the list is empty.
  487. `a.rear()'
  488.      returns a reference to the rear of the list, or triggers an error
  489.      if the list is empty.
  490. `x = a.remove_front()'
  491.      deletes and returns the item stored at the head of the list.
  492. `a.del_front()'
  493.      deletes the first element, without returning it.
  494. `a.clear()'
  495.      deletes all items from the list.
  496. `a.ins_after(Pix i, item);'
  497.      inserts item after position i. If i is null, insertion is at the
  498.      front.
  499. `a.del_after(Pix i);'
  500.      deletes the element following i. If i is 0, the first item is
  501.      deleted.
  502. Doubly linked lists
  503. ===================
  504.    Class `DLList' supports the following additional operations, as well
  505. as backward traversal via Pixes.
  506. `x = a.remove_rear();'
  507.      deletes and returns the item stored at the rear of the list.
  508. `a.del_rear();'
  509.      deletes the last element, without returning it.
  510. `a.ins_before(Pix i, x)'
  511.      inserts x before the i.
  512. `a.del(Pix& iint dir = 1)'
  513.      deletes the item at the current position, then advances forward if
  514.      dir is positive, else backward.
  515. File: libgpp,  Node: Vector,  Next: Plex,  Prev: LinkList,  Up: Top
  516. Vector classes
  517. **************
  518.    The files `g++-include/Vec.ccP' and `g++-include/AVec.ccP' provide
  519. pseudo-generic standard array-based vector operations.  The
  520. corresponding header files are `g++-include/Vec.hP' and
  521. `g++-include/AVec.hP'.  Class `Vec' provides operations suitable for
  522. any base class that includes an equality operator. Subclass `AVec'
  523. provides additional arithmetic operations suitable for base classes
  524. that include the full complement of arithmetic operators.
  525.    `Vecs' are constructed and assigned by copying. Thus, they should
  526. normally be passed by reference in applications programs.
  527.    Several mapping functions are provided that allow programmers to
  528. specify operations on vectors as a whole.
  529.    For illustrative purposes assume that classes `intVec' and `intAVec'
  530. have been generated via `genclass'.
  531. Constructors and assignment
  532. ===========================
  533. `intVec a;'
  534.      declares a to be an empty vector. Its size may be changed via
  535.      resize.
  536. `intVec a(10);'
  537.      declares a to be an uninitialized vector of ten elements (numbered
  538.      0-9).
  539. `intVec b(6, 0);'
  540.      declares b to be a vector of six elements, all initialized to
  541.      zero. Any value can be used as the initial fill argument.
  542. `a = b;'
  543.      Copies b to a. a is resized to be the same as b.
  544. `a = b.at(2, 4)'
  545.      constructs a from the 4 elements of b starting at b[2].
  546.    Assume declarations of `intVec a, b, c' and `int i, x' in the
  547. following.
  548. Status and access
  549. =================
  550. `a.capacity();'
  551.      returns the number of elements that can be held in a.
  552. `a.resize(20);'
  553.      sets a's length to 20. All elements are unchanged, except that if
  554.      the new size is smaller than the original, than trailing elements
  555.      are deleted, and if greater, trailing elements are uninitialized.
  556. `a[i];'
  557.      returns a reference to the i'th element of a, or produces an error
  558.      if i is out of range.
  559. `a.elem(i)'
  560.      returns a reference to the i'th element of a. Unlike the `[]'
  561.      operator, i is not checked to ensure that it is within range.
  562. `a == b;'
  563.      returns true if a and b contain the same elements in the same
  564.      order.
  565. `a != b;'
  566.      is the converse of a == b.
  567. Constructive operations
  568. =======================
  569. `c = concat(a, b);'
  570.      sets c to the new vector constructed from all of the elements of a
  571.      followed by all of b.
  572. `c = map(f, a);'
  573.      sets c to the new vector constructed by applying int function
  574.      f(int) to each element of a.
  575. `c = merge(a, b, f);'
  576.      sets c to the new vector constructed by merging the elements of
  577.      ordered vectors a and b using ordering (comparison) function f.
  578. `c = combine(f, a, b);'
  579.      sets c to the new vector constructed by applying int function
  580.      f(int, int) to successive pairs of a and b. The result has length
  581.      the shorter of a and b.
  582. `c = reverse(a)'
  583.      sets c to a, with elements in reverse order.
  584. Destructive operations
  585. ======================
  586. `a.reverse();'
  587.      reverses a in-place.
  588. `a.sort(f)'
  589.      sorts a in-place using comparison function f. The sorting method
  590.      is a variation of the quicksort functions supplied with GNU emacs.
  591. `a.fill(0, 4, 2)'
  592.      fills the 2 elements starting at a[4] with zero.
  593. Other operations
  594. ================
  595. `a.apply(f)'
  596.      applies function f to each element in a.
  597. `x = a.reduce(f, base)'
  598.      accumulates the results of applying function f to successive
  599.      elements of a starting with base.
  600. `a.index(int targ);'
  601.      returns the index of the leftmost occurrence of the target, or -1,
  602.      if it does not occur.
  603. `a.error(char* msg)'
  604.      invokes the error handler. The default version prints the error
  605.      message, then aborts.
  606. AVec operations.
  607. ================
  608.    AVecs provide additional arithmetic operations.  All vector-by-vector
  609. operators generate an error if the vectors are not the same length. The
  610. following operations are provided, for `AVecs a, b' and base element
  611. (scalar) `s'.
  612. `a = b;'
  613.      Copies b to a. a and b must be the same size.
  614. `a = s;'
  615.      fills all elements of a with the value s. a is not resized.
  616. `a + s; a - s; a * s; a / s'
  617.      adds, subtracts, multiplies, or divides each element of a with the
  618.      scalar.
  619. `a += s; a -= s; a *= s; a /= s;'
  620.      adds, subtracts, multiplies, or divides the scalar into a.
  621. `a + b; a - b; product(a, b), quotient(a, b)'
  622.      adds, subtracts, multiplies, or divides corresponding elements of
  623.      a and b.
  624. `a += b; a -= b; a.product(b); a.quotient(b);'
  625.      adds, subtracts, multiplies, or divides corresponding elements of
  626.      b into a.
  627. `s = a * b;'
  628.      returns the inner (dot) product of a and b.
  629. `x = a.sum();'
  630.      returns the sum of elements of a.
  631. `x = a.sumsq();'
  632.      returns the sum of squared elements of a.
  633. `x = a.min();'
  634.      returns the minimum element of a.
  635. `x = a.max();'
  636.      returns the maximum element of a.
  637. `i = a.min_index();'
  638.      returns the index of the minimum element of a.
  639. `i = a.max_index();'
  640.      returns the index of the maximum element of a.
  641.      Note that it is possible to apply vector versions other arithmetic
  642.      operators via the mapping functions. For example, to set vector b
  643.      to the  cosines of doubleVec a, use `b = map(cos, a);'. This is
  644.      often more efficient than performing the operations in an
  645.      element-by-element fashion.
  646. File: libgpp,  Node: Plex,  Next: Stack,  Prev: Vector,  Up: Top
  647. Plex classes
  648. ************
  649.    A "Plex" is a kind of array with the following properties:
  650.    * Plexes may have arbitrary upper and lower index bounds. For example
  651.      a Plex may be declared to run from indices -10 .. 10.
  652.    * Plexes may be dynamically expanded at both the lower and upper
  653.      bounds of the array in steps of one element.
  654.    * Only elements that have been specifically initialized or added may
  655.      be accessed.
  656.    * Elements may be accessed via indices. Indices are always checked
  657.      for validity at run time.  Plexes may be traversed via simple
  658.      variations of standard array indexing loops.
  659.    * Plex elements may be accessed and traversed via Pixes.
  660.    * Plex-to-Plex assignment and related operations on entire Plexes
  661.      are supported.
  662.    * Plex classes contain methods to help programmers check the validity
  663.      of indexing and pointer operations.
  664.    * Plexes form "natural" base classes for many restricted-access data
  665.      structures relying on logically contiguous indices, such as
  666.      array-based stacks and queues.
  667.    * Plexes are implemented as pseudo-generic classes, and must be
  668.      generated via the `genclass' utility.
  669.    Four subclasses of Plexes are supported: A `FPlex' is a Plex that
  670. may only grow or shrink within declared bounds; an `XPlex' may
  671. dynamically grow or shrink without bounds; an `RPlex' is the same as an
  672. `XPlex' but better supports indexing with poor locality of reference; a
  673. `MPlex' may grow or shrink, and additionally allows the logical
  674. deletion and restoration of elements. Because these classes are virtual
  675. subclasses of the "abstract" class `Plex', it is possible to write user
  676. code such as `void f(Plex& a) ...' that operates on any kind of Plex.
  677. However, as with nearly any virtual class, specifying the particular
  678. Plex class being used results in more efficient code.
  679.    Plexes are implemented as a linked list of `IChunks'.  Each chunk
  680. contains a part of the array. Chunk sizes may be specified within Plex
  681. constructors.  Default versions also exist, that use a `#define'd'
  682. default.  Plexes grow by filling unused space in existing chunks, if
  683. possible, else, except for FPlexes, by adding another chunk.  Whenever
  684. Plexes grow by a new chunk, the default element constructors (i.e.,
  685. those which take no arguments) for all chunk elements are called at
  686. once. When Plexes shrink, destructors for the elements are not called
  687. until an entire chunk is freed. For this reason, Plexes (like C++
  688. arrays) should only be used for elements with default constructors and
  689. destructors that have no side effects.
  690.    Plexes may be indexed and used like arrays, although traversal
  691. syntax is slightly different. Even though Plexes maintain elements in
  692. lists of chunks, they are implemented so that iteration and other
  693. constructs that maintain locality of reference require very little
  694. overhead over that for simple array traversal Pix-based traversal is
  695. also supported. For example, for a plex, p, of ints, the following
  696. traversal methods could be used.
  697.      for (int i = p.low(); i < p.fence(); p.next(i)) use(p[i]);
  698.      for (int i = p.high(); i > p.ecnef(); p.prev(i)) use(p[i]);
  699.      for (Pix t = p.first(); t != 0; p.next(t)) use(p(i));
  700.      for (Pix t = p.last(); t != 0; p.prev(t)) use(p(i));
  701.    Except for MPlexes, simply using `++i' and `--i' works just as well
  702. as `p.next(i)' and `p.prev(i)' when traversing by index. Index-based
  703. traversal is generally a bit faster than Pix-based traversal.
  704.    `XPlexes' and `MPlexes' are less than optimal for applications in
  705. which widely scattered elements are indexed, as might occur when using
  706. Plexes as hash tables or "manually" allocated linked lists. In such
  707. applications, `RPlexes' are often preferable. `RPlexes' use a secondary
  708. chunk index table that requires slightly greater, but entirely uniform
  709. overhead per index operation.
  710.    Even though they may grow in either direction, Plexes are normally
  711. constructed so that their "natural" growth direction is upwards, in
  712. that default chunk construction leaves free space, if present, at the
  713. end of the plex. However, if the chunksize arguments to constructors
  714. are negative, they leave space at the beginning.
  715.    All versions of Plexes support the following basic capabilities.
  716. (letting `Plex' stand for the type name constructed via the genclass
  717. utility (e.g., `intPlex', `doublePlex')).  Assume declarations of `Plex
  718. p, q', `int i, j', base element `x', and Pix `pix'.
  719. `Plex p;'
  720.      Declares p to be an initially zero-sized Plex with low index of
  721.      zero, and the default chunk size. For FPlexes, chunk sizes
  722.      represent maximum sizes.
  723. `Plex p(int size);'
  724.      Declares p to be an initially zero-sized Plex with low index of
  725.      zero, and the indicated chunk size. If size is negative, then the
  726.      Plex is created with free space at the beginning of the Plex,
  727.      allowing more efficient add_low() operations. Otherwise, it leaves
  728.      space at the end.
  729. `Plex p(int low, int size);'
  730.      Declares p to be an initially zero-sized Plex with low index of
  731.      low, and the indicated chunk size.
  732. `Plex p(int low, int high, Base initval, int size = 0);'
  733.      Declares p to be a Plex with indices from low to high, initially
  734.      filled with initval, and the indicated chunk size if specified,
  735.      else the default or (high - low + 1), whichever is greater.
  736. `Plex q(p);'
  737.      Declares q to be a copy of p.
  738. `p = q;'
  739.      Copies Plex q into p, deleting its previous contents.
  740. `p.length()'
  741.      Returns the number of elements in the Plex.
  742. `p.empty()'
  743.      Returns true if Plex p contains no elements.
  744. `p.full()'
  745.      Returns true if Plex p cannot be expanded. This always returns
  746.      false for XPlexes and MPlexes.
  747. `p[i]'
  748.      Returns a reference to the i'th element of p. An exception (error)
  749.      occurs if i is not a valid index.
  750. `p.valid(i)'
  751.      Returns true if i is a valid index into Plex p.
  752. `p.low(); p.high();'
  753.      Return the minimum (maximum) valid index of the Plex, or the high
  754.      (low) fence if the plex is empty.
  755. `p.ecnef(); p.fence();'
  756.      Return the index one position past the minimum (maximum) valid
  757.      index.
  758. `p.next(i); i = p.prev(i);'
  759.      Set i to the next (previous) index. This index may not be within
  760.      bounds.
  761. `p(pix)'
  762.      returns a reference to the item at Pix pix.
  763. `pix = p.first(); pix = p.last();'
  764.      Return the minimum (maximum) valid Pix of the Plex, or 0 if the
  765.      plex is empty.
  766. `p.next(pix); p.prev(pix);'
  767.      set pix to the next (previous) Pix, or 0 if there is none.
  768. `p.owns(pix)'
  769.      Returns true if the Plex contains the element associated with pix.
  770. `p.Pix_to_index(pix)'
  771.      If pix is a valid Pix to an element of the Plex, returns its
  772.      corresponding index, else raises an exception.
  773. `ptr = p.index_to_Pix(i)'
  774.      if i is a valid index, returns a the corresponding Pix.
  775. `p.low_element(); p.high_element();'
  776.      Return a reference to the element at the minimum (maximum) valid
  777.      index. An exception occurs if the Plex is empty.
  778. `p.can_add_low();  p.can_add_high();'
  779.      Returns true if the plex can be extended one element downward
  780.      (upward). These always return true for XPlex and MPlex.
  781. `j = p.add_low(x); j = p.add_high(x);'
  782.      Extend the Plex by one element downward (upward). The new minimum
  783.      (maximum) index is returned.
  784. `j = p.del_low(); j = p.del_high()'
  785.      Shrink the Plex by one element on the low (high) end. The new
  786.      minimum (maximum) element is returned. An exception occurs if the
  787.      Plex is empty.
  788. `p.append(q);'
  789.      Append all of Plex q to the high side of p.
  790. `p.prepend(q);'
  791.      Prepend all of q to the low side of p.
  792. `p.clear()'
  793.      Delete all elements, resetting p to a zero-sized Plex.
  794. `p.reset_low(i);'
  795.      Resets p to be indexed starting at low() = i. For example. if p
  796.      were initially declared via `Plex p(0, 10, 0)', and then
  797.      re-indexed via `p.reset_low(5)', it could then be indexed from
  798.      indices 5 .. 14.
  799. `p.fill(x)'
  800.      sets all p[i] to x.
  801. `p.fill(x, lo, hi)'
  802.      sets all of p[i] from lo to hi, inclusive, to x.
  803. `p.reverse()'
  804.      reverses p in-place.
  805. `p.chunk_size()'
  806.      returns the chunk size used for the plex.
  807. `p.error(const char * msg)'
  808.      calls the resettable error handler.
  809.    MPlexes are plexes with bitmaps that allow items to be logically
  810. deleted and restored. They behave like other plexes, but also support
  811. the following additional and modified capabilities:
  812. `p.del_index(i); p.del_Pix(pix)'
  813.      logically deletes p[i] (p(pix)). After deletion, attempts to
  814.      access p[i] generate a error. Indexing via low(), high(), prev(),
  815.      and next() skip the element. Deleting an element never changes the
  816.      logical bounds of the plex.
  817. `p.undel_index(i); p.undel_Pix(pix)'
  818.      logically undeletes p[i] (p(pix)).
  819. `p.del_low(); p.del_high()'
  820.      Delete the lowest (highest) undeleted element, resetting the
  821.      logical bounds of the plex to the next lowest (highest) undeleted
  822.      index. Thus, MPlex del_low() and del_high() may shrink the bounds
  823.      of the plex by more than one index.
  824. `p.adjust_bounds()'
  825.      Resets the low and high bounds of the Plex to the indexes of the
  826.      lowest and highest actual undeleted elements.
  827. `int i = p.add(x)'
  828.      Adds x in an unused index, if possible, else performs add_high.
  829. `p.count()'
  830.      returns the number of valid (undeleted) elements.
  831. `p.available()'
  832.      returns the number of available (deleted) indices.
  833. `int i = p.unused_index()'
  834.      returns the index of some deleted element, if one exists, else
  835.      triggers an error. An unused element may be reused via undel.
  836. `pix = p.unused_Pix()'
  837.      returns the pix of some deleted element, if one exists, else 0. An
  838.      unused element may be reused via undel.
  839. File: libgpp,  Node: Stack,  Next: Queue,  Prev: Plex,  Up: Top
  840. Stacks
  841. ******
  842.    Stacks are declared as an "abstract" class. They are currently
  843. implemented in any of three ways.
  844. `VStack'
  845.      implement fixed sized stacks via arrays.
  846. `XPStack'
  847.      implement dynamically-sized stacks via XPlexes.
  848. `SLStack'
  849.      implement dynamically-size stacks via linked lists.
  850.    All possess the same capabilities. They differ only in constructors.
  851. VStack constructors require a fixed maximum capacity argument. XPStack
  852. constructors optionally take a chunk size argument. SLStack
  853. constructors take no argument.
  854.    Assume the declaration of a base element `x'.
  855. `Stack s;  or Stack s(int capacity)'
  856.      declares a Stack.
  857. `s.empty()'
  858.      returns true if stack s is empty.
  859. `s.full()'
  860.      returns true if stack s is full. XPStacks and SLStacks never
  861.      become full.
  862. `s.length()'
  863.      returns the current number of elements in the stack.
  864. `s.push(x)'
  865.      pushes x on stack s.
  866. `x = s.pop()'
  867.      pops and returns the top of stack
  868. `s.top()'
  869.      returns a reference to the top of stack.
  870. `s.del_top()'
  871.      pops, but does not return the top of stack. When large items are
  872.      held on the stack it is often a good idea to use `top()' to
  873.      inspect and use the top of stack, followed by a `del_top()'
  874. `s.clear()'
  875.      removes all elements from the stack.
  876. File: libgpp,  Node: Queue,  Next: Deque,  Prev: Stack,  Up: Top
  877. Queues
  878. ******
  879.    Queues are declared as an "abstract" class. They are currently
  880. implemented in any of three ways.
  881. `VQueue'
  882.      implement fixed sized Queues via arrays.
  883. `XPQueue'
  884.      implement dynamically-sized Queues via XPlexes.
  885. `SLQueue'
  886.      implement dynamically-size Queues via linked lists.
  887.    All possess the same capabilities; they differ only in constructors.
  888. `VQueue' constructors require a fixed maximum capacity argument.
  889. `XPQueue' constructors optionally take a chunk size argument. `SLQueue'
  890. constructors take no argument.
  891.    Assume the declaration of a base element `x'.
  892. `Queue q; or Queue q(int capacity);'
  893.      declares a queue.
  894. `q.empty()'
  895.      returns true if queue q is empty.
  896. `q.full()'
  897.      returns true if queue q is full. XPQueues and SLQueues are never
  898.      full.
  899. `q.length()'
  900.      returns the current number of elements in the queue.
  901. `q.enq(x)'
  902.      enqueues x on queue q.
  903. `x = q.deq()'
  904.      dequeues and returns the front of queue
  905. `q.front()'
  906.      returns a reference to the front of queue.
  907. `q.del_front()'
  908.      dequeues, but does not return the front of queue
  909. `q.clear()'
  910.      removes all elements from the queue.
  911. File: libgpp,  Node: Deque,  Next: PQ,  Prev: Queue,  Up: Top
  912. Double ended Queues
  913. *******************
  914.    Deques are declared as an "abstract" class. They are currently
  915. implemented in two ways.
  916. `XPDeque'
  917.      implement dynamically-sized Deques via XPlexes.
  918. `DLDeque'
  919.      implement dynamically-size Deques via linked lists.
  920.    All possess the same capabilities. They differ only in constructors.
  921. XPDeque constructors optionally take a chunk size argument. DLDeque
  922. constructors take no argument.
  923.    Double-ended queues support both stack-like and queue-like
  924. capabilities:
  925.    Assume the declaration of a base element `x'.
  926. `Deque d; or Deque d(int initial_capacity)'
  927.      declares a deque.
  928. `d.empty()'
  929.      returns true if deque d is empty.
  930. `d.full()'
  931.      returns true if deque d is full. Always returns false in current
  932.      implementations.
  933. `d.length()'
  934.      returns the current number of elements in the deque.
  935. `d.enq(x)'
  936.      inserts x at the rear of deque d.
  937. `d.push(x)'
  938.      inserts x at the front of deque d.
  939. `x = d.deq()'
  940.      dequeues and returns the front of deque
  941. `d.front()'
  942.      returns a reference to the front of deque.
  943. `d.rear()'
  944.      returns a reference to the rear of the deque.
  945. `d.del_front()'
  946.      deletes, but does not return the front of deque
  947. `d.del_rear()'
  948.      deletes, but does not return the rear of the deque.
  949. `d.clear()'
  950.      removes all elements from the deque.
  951. File: libgpp,  Node: PQ,  Next: Set,  Prev: Deque,  Up: Top
  952. Priority Queue class prototypes.
  953. ********************************
  954.    Priority queues maintain collections of objects arranged for fast
  955. access to the least element.
  956.    Several prototype implementations of priority queues are supported.
  957. `XPPQs'
  958.      implement 2-ary heaps via XPlexes.
  959. `SplayPQs'
  960.      implement  PQs via Sleater and Tarjan's (JACM 1985) splay trees.
  961.      The algorithms use a version of "simple top-down splaying"
  962.      (described on page 669 of the article).  The simple-splay
  963.      mechanism for priority queue functions is loosely based on the one
  964.      used by D. Jones in the C splay tree functions available from
  965.      volume 14 of the uunet.uu.net archives.
  966. `PHPQs'
  967.      implement pairing heaps (as described by Fredman and Sedgewick in
  968.      `Algorithmica', Vol 1, p111-129).  Storage for heap elements is
  969.      managed via an internal freelist technique. The constructor allows
  970.      an initial capacity estimate for freelist space.  The storage is
  971.      automatically expanded if necessary to hold new items. The
  972.      deletion technique is a fast "lazy deletion" strategy that marks
  973.      items as deleted, without reclaiming space until the items come to
  974.      the top of the heap.
  975.    All PQ classes support the following operations, for some PQ class
  976. `Heap', instance `h', `Pix ind', and base class variable `x'.
  977. `h.empty()'
  978.      returns true if there are no elements in the PQ.
  979. `h.length()'
  980.      returns the number of elements in h.
  981. `ind = h.enq(x)'
  982.      Places x in the PQ, and returns its index.
  983. `x = h.deq()'
  984.      Dequeues the minimum element of the PQ into x, or generates an
  985.      error if the PQ is empty.
  986. `h.front()'
  987.      returns a reference to the minimum element.
  988. `h.del_front()'
  989.      deletes the minimum element.
  990. `h.clear();'
  991.      deletes all elements from h;
  992. `h.contains(x)'
  993.      returns true if x is in h.
  994. `h(ind)'
  995.      returns a reference to the item indexed by ind.
  996. `ind = h.first()'
  997.      returns the Pix of first item in the PQ or 0 if empty. This need
  998.      not be the Pix of the least element.
  999. `h.next(ind)'
  1000.      advances ind to the Pix of next element, or 0 if there are no more.
  1001. `ind = h.seek(x)'
  1002.      Sets ind to the Pix of x, or 0 if x is not in h.
  1003. `h.del(ind)'
  1004.      deletes the item with Pix ind.
  1005. File: libgpp,  Node: Set,  Next: Bag,  Prev: PQ,  Up: Top
  1006. Set class prototypes
  1007. ********************
  1008.    Set classes maintain unbounded collections of items containing no
  1009. duplicate elements.
  1010.    These are currently implemented in several ways, differing in
  1011. representation strategy, algorithmic efficiency, and appropriateness for
  1012. various tasks. (Listed next to each are average (followed by worst-case,
  1013. if different) time complexities for [a] adding, [f] finding (via seek,
  1014. contains), [d] deleting, elements, and [c] comparing (via ==, <=) and
  1015. [m] merging (via |=, -=, &=) sets).
  1016. `XPSets'
  1017.      implement unordered sets via XPlexes. ([a O(n)], [f O(n)], [d
  1018.      O(n)], [c O(n^2)] [m O(n^2)]).
  1019. `OXPSets'
  1020.      implement ordered sets via XPlexes. ([a O(n)], [f O(log n)], [d
  1021.      O(n)], [c O(n)] [m O(n)]).
  1022. `SLSets'
  1023.      implement unordered sets via linked lists ([a O(n)], [f O(n)], [d
  1024.      O(n)], [c O(n^2)] [m O(n^2)]).
  1025. `OSLSets'
  1026.      implement ordered sets via linked lists ([a O(n)], [f O(n)], [d
  1027.      O(n)], [c O(n)] [m O(n)]).
  1028. `AVLSets'
  1029.      implement ordered sets via threaded AVL trees ([a O(log n)], [f
  1030.      O(log n)], [d O(log n)], [c O(n)] [m O(n)]).
  1031. `BSTSets'
  1032.      implement ordered sets via binary search trees. The trees may be
  1033.      manually rebalanced via the O(n) `balance()' member function. ([a
  1034.      O(log n)/O(n)], [f O(log n)/O(n)], [d O(log n)/O(n)], [c O(n)] [m
  1035.      O(n)]).
  1036. `SplaySets'
  1037.      implement ordered sets via Sleater and Tarjan's (JACM 1985) splay
  1038.      trees. The algorithms use a version of "simple top-down splaying"
  1039.      (described on page 669 of the article). (Amortized: [a O(log n)],
  1040.      [f O(log n)], [d O(log n)], [c O(n)] [m O(n log n)]).
  1041. `VHSets'
  1042.      implement unordered sets via hash tables. The tables are
  1043.      automatically resized when their capacity is exhausted. ([a
  1044.      O(1)/O(n)], [f O(1)/O(n)], [d O(1)/O(n)], [c O(n)/O(n^2)] [m
  1045.      O(n)/O(n^2)]).
  1046. `VOHSets'
  1047.      implement unordered sets via ordered hash tables The tables are
  1048.      automatically resized when their capacity is exhausted. ([a
  1049.      O(1)/O(n)], [f O(1)/O(n)], [d O(1)/O(n)], [c O(n)/O(n^2)] [m
  1050.      O(n)/O(n^2)]).
  1051. `CHSets'
  1052.      implement unordered sets via chained hash tables. ([a O(1)/O(n)],
  1053.      [f O(1)/O(n)], [d O(1)/O(n)], [c O(n)/O(n^2)] [m O(n)/O(n^2)]).
  1054.    The different implementations differ in whether their constructors
  1055. require an argument specifying their initial capacity. Initial
  1056. capacities are required for plex and hash table based Sets.  If none is
  1057. given `DEFAULT_INITIAL_CAPACITY' (from `<T>defs.h') is used.
  1058.    Sets support the following operations, for some class `Set',
  1059. instances `a' and `b', `Pix ind', and base element `x'. Since all
  1060. implementations are virtual derived classes of the `<T>Set' class, it
  1061. is possible to mix and match operations across different
  1062. implementations, although, as usual, operations are generally faster
  1063. when the particular classes are specified in functions operating on
  1064. Sets.
  1065.    Pix-based operations are more fully described in the section on
  1066. Pixes. *Note Pix::
  1067. `Set a; or Set a(int initial_size);'
  1068.      Declares a to be an empty Set. The second version is allowed in
  1069.      set classes that require initial capacity or sizing specifications.
  1070. `a.empty()'
  1071.      returns true if a is empty.
  1072. `a.length()'
  1073.      returns the number of elements in a.
  1074. `Pix ind = a.add(x)'
  1075.      inserts x into a, returning its index.
  1076. `a.del(x)'
  1077.      deletes x from a.
  1078. `a.clear()'
  1079.      deletes all elements from a;
  1080. `a.contains(x)'
  1081.      returns true if x is in a.
  1082. `a(ind)'
  1083.      returns a reference to the item indexed by ind.
  1084. `ind = a.first()'
  1085.      returns the Pix of first item in the set or 0 if the Set is empty.
  1086.      For ordered Sets, this is the Pix of the least element.
  1087. `a.next(ind)'
  1088.      advances ind to the Pix of next element, or 0 if there are no more.
  1089. `ind = a.seek(x)'
  1090.      Sets ind to the Pix of x, or 0 if x is not in a.
  1091. `a == b'
  1092.      returns true if a and b contain all the same elements.
  1093. `a != b'
  1094.      returns true if a and b do not contain all the same elements.
  1095. `a <= b'
  1096.      returns true if a is a subset of b.
  1097. `a |= b'
  1098.      Adds all elements of b to a.
  1099. `a -= b'
  1100.      Deletes all elements of b from a.
  1101. `a &= b'
  1102.      Deletes all elements of a not occurring in b.
  1103.