The Stanford C++ libraries are currently maintained by Marty Stepp (stepp AT stanford DOT edu). Download the latest version of the C++ library here:


The StanfordCPPLib package defines a set of libraries that make it easier to write programs in C++. The facilities provided by these libraries can be broken down into the following groups:
  1. Function libraries. Several of the interfaces (console.h, direction.h, error.h, filelib.h, gmath.h, random.h, simpio.h, strlib.h, thread.h) export collections of free functions instead of classes.

  2. Collection classes. Several of the classes (BasicGraph, DawgLexicon, Graph, Grid, HashMap, HashSet, Lexicon, LinkedList, Map, PriorityQueue, Queue, Set, SparseGrid, Stack, Vector) represent collections of other objects. These collections work in much the same way as the similar classes in the Standard Template Library (STL).

  3. Graphics classes. Most of the classes in the StanfordCPPLib package are used to support graphics. These classes can themselves be broken down into the following categories:
  4. Utility classes. The libraries also export several utility classes that don’t fit easily into the other categories (ErrorException, Lock, Point, Sound, Thread, TokenScanner).

Additional documentation appears in the web pages for the individual classes, along with sample code.
Classes
BasicGraph This class is used to represent a graph, building on the Graph class.
DawgLexicon This class is used to represent a lexicon, or word list.
Edge This class represents edges (arcs) in a graph.
ErrorException This exception is thrown by calls to the error function.
G3DRect This graphical object subclass represents a rectangular box that can be raised or lowered.
GActionEvent This event subclass represents an action event.
GArc This graphical object subclass represents an elliptical arc.
GButton This interactor subclass represents an onscreen button.
GCheckBox This interactor subclass represents an onscreen check box.
GChooser This interactor subclass represents a selectable list.
GCompound This graphical object subclass consists of a collection of other graphical objects.
GDimension This class contains real-valued width and height fields.
GEvent This class is the root of the hierarchy for all events.
GImage This graphical object subclass represents an image from a file.
GInteractor This abstract class is the superclass for all graphical interactors.
GKeyEvent This event subclass represents a key event.
GLabel This graphical object subclass represents a text string.
GLine This graphical object subclass represents a line segment.
GMouseEvent This event subclass represents a mouse event.
GObject This class is the common superclass of all graphical objects that can be displayed on a graphical window.
GOval This graphical object subclass represents an oval inscribed in a rectangular box.
GPoint This class contains real-valued x and y fields.
GPolygon This graphical object subclass represents a polygon bounded by line segments.
Graph<NodeType,ArcType> This class represents a graph with the specified node and arc types.
GRect This class represents a graphical object whose appearance consists of a rectangular box.
GRectangle This type contains real-valued x, y, width, and height fields.
Grid<ValueType> This class stores an indexed, two-dimensional array.
GRoundRect This class represents a graphical object whose appearance consists of a rectangular box with rounded corners.
GSlider This interactor subclass represents an onscreen slider.
GTextField This interactor subclass represents a text field for entering short text strings.
GTimer This class implements a simple interval timer that generates a GTimerEvent with a specified frequency.
GTimerEvent This event subclass represents a timer event.
GWindow This class represents a graphics window that supports simple graphics.
GWindowEvent This event subclass represents a window event.
HashMap<KeyType,ValueType> This class implements an efficient association between keys and values.
HashSet<ValueType> This class implements an efficient abstraction for storing sets of distinct elements.
ibitstream This base class reads bits of data from various input sources.
ifbitstream This class reads bits of data from input files.
istringbitstream This class reads bits of data from the characters of a string.
Lexicon This class is used to represent a lexicon, or word list.
LinkedList<ValueType> This class stores an ordered list of values similar to an array or vector.
Lock This class represents a simple lock used to control concurrency.
Map<KeyType,ValueType> This class maintains an association between keys and values.
obitstream This base class writes bits of data to various output sources.
ofbitstream This class writes bits of data to output files.
ostringbitstream This class writes bits of data into an internal string buffer.
Point This class represents an x-y coordinate point on a two-dimensional integer grid.
PriorityQueue<ValueType> This class models a structure called a priority queue in which values are processed in order of priority.
Queue<ValueType> This class models a linear structure called a queue in which values are added at one end and removed from the other.
Set<ValueType> This class stores a collection of distinct elements.
Sound This class encapsulates a sound file.
SparseGrid<ValueType> This class stores an indexed, two-dimensional array.
Stack<ValueType> This class models a linear structure called a stack in which values are added and removed only from one end.
Thread This class encapsulates a lightweight process running in the same address space as the creator.
Timer This class measures intervals of time while a program is running.
TokenScanner This class divides a string into individual tokens.
Vector<ValueType> This class stores an ordered list of values similar to an array.
Vertex This class represents vertices (nodes) in a graph.
Interface files
basicgraph.h This file exports a parameterized Graph class used to represent basic graphs, which consist of a set of vertexes and a set of edges.
bitstream.h This file exports the bit I/O stream classes, including ibitstream, ifbitstream, istringbitstream, obitstream, ofbitstream, and ostringbitstream.
console.h This file redirects the cin, cout, and cerr channels to use a console window.
dawglexicon.h This file exports the DawgLexicon class, which is a compact structure for storing a list of words.
direction.h This file exports an enumerated type called Direction whose elements are the four compass points: NORTH, EAST, SOUTH, and WEST.
error.h This file defines the ErrorException class and the error function.
filelib.h This file exports a standardized set of tools for working with files.
gevents.h This file defines the event types used in the StanfordCPPLib graphics libraries.
ginteractors.h This file exports a hierarchy of graphical interactors similar to those provided in the Java Swing libraries.
gmath.h This file exports several functions for working with graphical geometry along with the mathematical constants PI and E.
gobjects.h This file exports a hierarchy of graphical shapes based on the model developed for the ACM Java Graphics.
graph.h This file exports a parameterized Graph class used to represent graphs, which consist of a set of nodes and a set of arcs.
grid.h This file exports the Grid class, which offers a convenient abstraction for representing a two-dimensional array.
gtimer.h This file defines the GTimer class, which implements a general interval timer.
gtypes.h This file defines classes for representing points, dimensions, and rectangles.
gwindow.h This file defines the GWindow class which supports drawing graphical objects on the screen.
hashmap.h This file exports the HashMap class, which stores a set of key-value pairs.
hashset.h This file exports the HashSet class, which implements an efficient abstraction for storing sets of values.
lexicon.h This file exports the Lexicon class, which is a compact structure for storing a list of words.
linkedlist.h This file exports the LinkedList class, which provides an efficient, safe, convenient replacement for the array type in C++.
map.h This file exports the template class Map, which maintains a collection of key-value pairs.
point.h This file exports a class representing an integer-valued x-y pair.
pqueue.h This file exports the PriorityQueue class, a collection in which values are processed in priority order.
queue.h This file exports the Queue class, a collection in which values are ordinarily processed in a first-in/first-out (FIFO) order.
random.h This file exports functions for generating pseudorandom numbers.
set.h This file exports the Set class, which implements a collection for storing a set of distinct elements.
shuffle.h This file exports a set of functions that randomly rearrange arrays, grids, and vectors.
simpio.h This file exports a set of functions that simplify input/output operations in C++ and provide some error-checking on console input.
sound.h This file defines a class that represents a sound.
sparsegrid.h This file exports the SparseGrid class, which offers a convenient abstraction for representing a two-dimensional array.
stack.h This file exports the Stack class, which implements a collection that processes values in a last-in/first-out (LIFO) order.
strlib.h This file exports several useful string functions that are not included in the C++ string library.
thread.h This file exports a simple, platform-independent thread abstraction, along with simple tools for concurrency control.
timer.h This file exports a class for measuring intervals of time.
tokenscanner.h This file exports a TokenScanner class that divides a string into individual logical units called tokens.
vector.h This file exports the Vector class, which provides an efficient, safe, convenient replacement for the array type in C++.