The Stanford C++ libraries were originally developed by Stanford Professor Eric Roberts, with the assistance of Julie Zelenski, Keith Schwarz, and other Stanford colleagues. This documentation describes an unofficial modified version of the Stanford C++ libraries that is currently being used in Stanford's CS 106B/X courses. This unofficial modified version is written and maintained by Marty Stepp (stepp AT stanford DOT edu).
Previous versions of the C++ library used a Java backend called spl.jar to implement graphics and other functionality. The current version of the library now uses a new Qt-based GUI subsystem written by Marty Stepp that operates completely in C++. This means that the library no longer requires a Java JDK installation or spl.jar. The Qt C++ GUI system is new and may have some bugs as we integrate it into our project. Please report any bugs you find and/or submit a pull request!
We are sorry to say that we cannot offer support for the libraries to non-Stanford users at this time. You are welcome to use the libraries, but we cannot help with compiler issues or answer other technical questions.
Download the latest version of the modified C++ libraries here:
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:
console.h
,
direction.h
,
error.h
,
filelib.h
,
gmath.h
,
random.h
,
regexpr.h
,
simpio.h
,
strlib.h
export collections of free functions instead of classes.
BasicGraph
,
DawgLexicon
,
Deque
,
Graph
,
Grid
,
HashMap
,
HashSet
,
Lexicon
,
LinkedHashMap
,
LinkedHashSet
,
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).
StanfordCPPLib
package are used
to support graphics. These classes can themselves be broken down into
the following categories:
GWindow
class,
which represents a window that appears on the display screen
GObject
(G3DRect
,
GArc
,
GCompound
,
GImage
,
GLine
,
GOval
,
GPolygon
,
GRect
,
GRoundRect
GText
)
GBrowserPane
,
GButton
,
GCanvas
,
GCheckBox
,
GChooser
,
GColor
,
GColorChooser
,
GConsoleWindow
,
GContainer
,
GFileChooser
,
GFont
,
GLabel
,
GOptionPane
,
GRadioButton
,
GScrollBar
,
GScrollPane
,
GSlider
,
GTable
,
GTextArea
,
GTextField
)
GEvent
)
GDimension
,
GPoint
,
GRectangle
)
ErrorException
,
Point
,
Sound
,
TokenScanner
).
Additional documentation appears in the web pages for the individual classes, along with sample code.
Classes | |
This class is used to represent a graph, building on the Graph class. | |
This class is used to represent a lexicon, or word list. | |
This class is used to represent a deque, or double-ended queue. | |
This class represents edges (arcs) in a graph. | |
This exception is thrown by calls to the error function. | |
This graphical object subclass represents a rectangular box that can be raised or lowered. | |
This graphical object subclass represents an elliptical arc. | |
This interactor subclass represents a richly formatted pane that can render HTML pages. | |
This interactor subclass represents an onscreen button. | |
This class implements a 2D region of colored pixels that can be read/set individually. | |
This interactor subclass represents an onscreen check box. | |
This interactor subclass represents a selectable list. | |
This class contains utility methods for copying and pasting text from the system clipboard. | |
This class contains utility methods for working with colors. | |
This class represents a dialog box for selecting a color from a swatch. | |
This graphical object subclass consists of a collection of other graphical objects. | |
This class represents our onscreen graphical console window. | |
This class represents layout containers for graphical interactors. | |
This class contains real-valued width and height fields. | |
This class helps download resources from URLs. | |
This class is the root of the hierarchy for all events. | |
This class represents a dialog box for selecting a file. | |
This class contains utility methods for working with fonts. | |
This class represents a dialog box for selecting a font from a list. | |
This graphical object subclass represents an image from a file. | |
This abstract class is the superclass for all graphical interactors. | |
This graphical object subclass represents a text string. | |
This graphical object subclass represents a line segment. | |
This class is the common superclass of all graphical objects that can be displayed on a graphical window. | |
This class represents graphical input/output dialog boxes that can be popped up on the screen. | |
This graphical object subclass represents an oval inscribed in a rectangular box. | |
This class contains real-valued x and y fields. | |
This graphical object subclass represents a polygon bounded by line segments. | |
This class represents a graph with the specified node and arc types. | |
This class represents a checkable circle button that is part of a mutually exclusive group. | |
This class represents a graphical object whose appearance consists of a rectangular box. | |
This type contains real-valued x, y, width, and height fields. | |
This class stores an indexed, two-dimensional array. | |
This class represents a graphical object whose appearance consists of a rectangular box with rounded corners. | |
This interactor subclass represents a vertical or horizontal scroll bar. | |
This interactor subclass represents a container that can wrap vertical and/or horizontal scroll bars around another interactor. | |
This interactor subclass represents an onscreen slider. | |
This interactor subclass represents a 2D editable table of rows and columns. | |
This interactor subclass represents a multi-line text field for entering long text strings. | |
This interactor subclass represents a one-line text field for entering short text strings. | |
This class represents threads used for parallel execution. | |
This class implements a simple interval timer that generates a GTimerEvent with a specified frequency. | |
This class represents a graphics window that supports simple graphics. | |
This class implements an efficient association between keys and values. | |
This class implements an efficient abstraction for storing sets of distinct elements. | |
This base class reads bits of data from various input sources. | |
This class reads bits of data from input files. | |
This class reads bits of data from the characters of a string. | |
This class reads bytes of data from the web using URLs. | |
This class is used to represent a lexicon, or word list. | |
This class implements an efficient association between keys and values and remembers the order of insertion. | |
This class implements an efficient abstraction for storing sets of distinct elements and remembers the order of insertion. | |
This class stores an ordered list of values similar to an array or vector. | |
This class represents a simple lock used to control concurrency. | |
This class maintains an association between keys and values. | |
This base class writes bits of data to various output sources. | |
This class writes bits of data to output files. | |
This class writes bits of data into an internal string buffer. | |
This class represents an x-y coordinate point on a two-dimensional integer grid. | |
This class models a structure called a priority queue in which values are processed in order of priority. | |
This class models a linear structure called a queue in which values are added at one end and removed from the other. | |
This class stores a collection of distinct elements. | |
This class encapsulates a sound file. | |
This class stores an indexed, two-dimensional array. | |
This class models a linear structure called a stack in which values are added and removed only from one end. | |
This class measures intervals of time while a program is running. | |
This class divides a string into individual tokens. | |
This class stores an ordered list of values similar to an array. | |
This class represents vertices (nodes) in a graph. |
Interface files | |
This file exports a parameterized BasicGraph class used to represent basic graphs, which consist of a set of vertexes and a set of edges. | |
This file exports the bit I/O stream classes, including ibitstream , ifbitstream , istringbitstream , obitstream , ofbitstream , and ostringbitstream . | |
This file redirects the cin , cout , and cerr channels to use a console window. | |
This file exports the DawgLexicon class, which is a compact structure for storing a list of words. | |
This file exports the Deque class, which is a double-ended queue. | |
This file exports an enumerated type called Direction whose elements are the four compass points: NORTH , EAST , SOUTH , and WEST . | |
This file defines the ErrorException class and the error function. | |
This file exports a standardized set of tools for working with files. | |
This file defines the event types used in the StanfordCPPLib graphics libraries. | |
This file exports a hierarchy of graphical interactors similar to those provided in the Java Swing libraries. | |
This file exports several functions for working with graphical geometry along with the mathematical constants PI and E . | |
This file exports a hierarchy of graphical shapes based on the model developed for the ACM Java Graphics. | |
This file exports a parameterized Graph class used to represent graphs, which consist of a set of nodes and a set of arcs. | |
This file exports the Grid class, which offers a convenient abstraction for representing a two-dimensional array. | |
This file defines the GTimer class, which implements a general interval timer. | |
This file defines classes for representing points, dimensions, and rectangles. | |
This file defines the GWindow class which supports drawing graphical objects on the screen. | |
This file exports the HashMap class, which stores a set of key-value pairs. | |
This file exports the HashSet class, which implements an efficient abstraction for storing sets of values. | |
This file exports the Lexicon class, which is a compact structure for storing a list of words. | |
This file exports the LinkedHashMap class, which stores a set of key-value pairs in order of insertion. | |
This file exports the LinkedHashSet class, which implements an efficient abstraction for storing sets of values in order of insertion. | |
This file exports the LinkedList class, which provides an efficient, safe, convenient replacement for the array type in C++. | |
This file exports the template class Map , which maintains a collection of key-value pairs. | |
This file exports a class representing an integer-valued x-y pair. | |
This file exports the PriorityQueue class, a collection in which values are processed in priority order. | |
This file exports the Queue class, a collection in which values are ordinarily processed in a first-in/first-out (FIFO) order. | |
This file exports functions for generating pseudorandom numbers. | |
This file exports functions for processing regular expressions operations on C++ strings. | |
This file exports the Set class, which implements a collection for storing a set of distinct elements. | |
This file exports a set of functions that randomly rearrange arrays, grids, and vectors. | |
This file exports a set of functions that simplify input/output operations in C++ and provide some error-checking on console input. | |
This file defines a class that represents a sound. | |
This file exports the SparseGrid class, which offers a convenient abstraction for representing a two-dimensional array. | |
This file exports the Stack class, which implements a collection that processes values in a last-in/first-out (LIFO) order. | |
This file exports several useful string functions that are not included in the C++ string library. | |
This file exports a class for measuring intervals of time. | |
This file exports a TokenScanner class that divides a string into individual logical units called tokens. | |
This file exports the Vector class, which provides an efficient, safe, convenient replacement for the array type in C++. |