home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 5
/
FreshFish_July-August1994.bin
/
gnu
/
info
/
libg++.info-4
(
.txt
)
< prev
next >
Wrap
GNU Info File
|
1994-02-27
|
51KB
|
1,140 lines
This is Info file libg++.info, produced by Makeinfo-1.55 from the input
file ./libg++.texi.
START-INFO-DIR-ENTRY
* Libg++:: The g++ class library.
END-INFO-DIR-ENTRY
This file documents the features and implementation of The GNU C++
library
Copyright (C) 1988, 1991, 1992 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided also
that the section entitled "GNU Library General Public License" is
included exactly as in the original, and provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that the section entitled "GNU Library General Public
License" and this permission notice may be included in translations
approved by the Free Software Foundation instead of in the original
English.
File: libg++.info, Node: Data, Next: Curses, Prev: Random, Up: Top
Data Collection
***************
Libg++ currently provides two classes for *data collection* and
analysis of the collected data.
SampleStatistic
===============
Class `SampleStatistic' provides a means of accumulating samples of
`double' values and providing common sample statistics.
Assume declaration of `double x'.
`SampleStatistic a;'
declares and initializes a.
`a.reset();'
re-initializes a.
`a += x;'
adds sample x.
`int n = a.samples();'
returns the number of samples.
`x = a.mean;'
returns the means of the samples.
`x = a.var()'
returns the sample variance of the samples.
`x = a.stdDev()'
returns the sample standard deviation of the samples.
`x = a.min()'
returns the minimum encountered sample.
`x = a.max()'
returns the maximum encountered sample.
`x = a.confidence(int p)'
returns the p-percent (0 <= p < 100) confidence interval.
`x = a.confidence(double p)'
returns the p-probability (0 <= p < 1) confidence interval.
SampleHistogram
===============
Class `SampleHistogram' is a derived class of `SampleStatistic' that
supports collection and display of samples in bucketed intervals. It
supports the following in addition to `SampleStatisic' operations.
`SampleHistogram h(double lo, double hi, double width);'
declares and initializes h to have buckets of size width from lo
to hi. If the optional argument width is not specified, 10
buckets are created. The first bucket and also holds samples less
than lo, and the last one holds samples greater than hi.
`int n = h.similarSamples(x)'
returns the number of samples in the same bucket as x.
`int n = h.inBucket(int i)'
returns the number of samples in bucket i.
`int b = h.buckets()'
returns the number of buckets.
`h.printBuckets(ostream s)'
prints bucket counts on ostream s.
`double bound = h.bucketThreshold(int i)'
returns the upper bound of bucket i.
File: libg++.info, Node: Curses, Next: List, Prev: Data, Up: Top
Curses-based classes
********************
The `CursesWindow' class is a repackaging of standard curses library
features into a class. It relies on `curses.h'.
The supplied `curses.h' is a fairly conservative declaration of
curses library features, and does not include features like "screen" or
X-window support. It is, for the most part, an adaptation, rather than
an improvement of C-based `curses.h' files. The only substantive
changes are the declarations of many functions as inline functions
rather than macros, which was done solely to allow overloading.
The `CursesWindow' class encapsulates curses window functions within
a class. Only those functions that control windows are included:
Terminal control functions and macros like `cbreak' are not part of the
class. All `CursesWindows' member functions have names identical to
the corresponding curses library functions, except that the "w" prefix
is generally dropped. Descriptions of these functions may be found in
your local curses library documentation.
A `CursesWindow' may be declared via
`CursesWindow w(WINDOW* win)'
attaches w to the existing WINDOW* win. This is constructor is
normally used only in the following special case.
`CursesWindow w(stdscr)'
attaches w to the default curses library standard screen window.
`CursesWindow w(int lines, int cols, int begin_y, int begin_x)'
attaches to an allocated curses window with the indicated size and
screen position.
`CursesWindow sub(CursesWindow& w,int l,int c,int by,int bx,char ar='a')'
attaches to a subwindow of w created via the curses `subwin'
command. If ar is sent as `r', the origin (by, bx) is relative to
the parent window, else it is absolute.
The class maintains a static counter that is used in order to
automatically call the curses library `initscr' and `endscr' functions
at the proper times. These need not, and should not be called
"manually".
`CursesWindow's maintain a tree of their subwindows. Upon
destruction of a `CursesWindow', all of their subwindows are also
invalidated if they had not previously been destroyed.
It is possible to traverse trees of subwindows via the following
member functions
`CursesWindow* w.parent()'
returns a pointer to the parent of the subwindow, or 0 if there is
none.
`CursesWindow* w.child()'
returns the first child subwindow of the window, or 0 if there is
none.
`CursesWindow* w.sibling()'
returns the next sibling of the subwindow, or 0 if there is none.
For example, to call some function `visit' for all subwindows of a
window, you could write
void traverse(CursesWindow& w)
{
visit(w);
if (w.child() != 0) traverse(*w.child);
if (w.sibling() != 0) traverse(*w.sibling);
}
File: libg++.info, Node: List, Next: LinkList, Prev: Curses, Up: Top
List classes
************
The files `g++-include/List.hP' and `g++-include/List.ccP' provide
pseudo-generic Lisp-type List classes. These lists are homogeneous
lists, more similar to lists in statically typed functional languages
like ML than Lisp, but support operations very similar to those found
in Lisp. Any particular kind of list class may be generated via the
`genclass' shell command. However, the implementation assumes that the
base class supports an equality operator `=='. All equality tests use
the `==' operator, and are thus equivalent to the use of `equal', not
`eq' in Lisp.
All list nodes are created dynamically, and managed via reference
counts. `List' variables are actually pointers to these list nodes.
Lists may also be traversed via Pixes, as described in the section
describing Pixes. *Note Pix::
Supported operations are mirrored closely after those in Lisp.
Generally, operations with functional forms are constructive,
functional operations, while member forms (often with the same name)
are sometimes procedural, possibly destructive operations.
As with Lisp, destructive operations are supported. Programmers are
allowed to change head and tail fields in any fashion, creating
circular structures and the like. However, again as with Lisp, some
operations implicitly assume that they are operating on pure lists, and
may enter infinite loops when presented with improper lists. Also, the
reference-counting storage management facility may fail to reclaim
unused circularly-linked nodes.
Several Lisp-like higher order functions are supported (e.g., `map').
Typedef declarations for the required functional forms are provided int
the `.h' file.
For purposes of illustration, assume the specification of class
`intList'. Common Lisp versions of supported operations are shown in
brackets for comparison purposes.
Constructors and assignment
===========================
`intList a; [ (setq a nil) ]'
Declares a to be a nil intList.
`intList b(2); [ (setq b (co