Code Examples
Random-Number Generator
Makefile
The following examples require GNU make, which is gmake on Solaris and make on Linux.
More information on make can be found here.
C++
-
Stream I/O: without exceptions (IO.cc) and with exceptions (IOexp.cc)
-
string class
-
sample program (string.cc) with test data StringTest illustrating a number of string
operations
-
doubly-linked list template in three versions
-
store copies of list-node in the list (List1.cc)
-
store pointers to list-node in the list (List2.cc)
-
template printList and find hack (List3.cc)
-
map example (Map.cc)
μC++
-
Stream I/O: with exceptions (uIO.cc)
-
Full coroutine example using the producer-consumer
problem (FullProdCons.cc)
-
Uses the full coroutine producer consumer code to show how to divide classes
into header and implementation files.
-
Header file for the consumer full coroutine (Cons.h)
-
Implementation of the consumer full coroutine (Cons.cc)
-
Header file for the producer full coroutine (Prod.h)
-
Implementation of the producer full coroutine (Prod.cc)
-
Driver for the program (ProdConsDriver.cc)
-
Using setName/getName (getName.cc)
-
Using uQueue (uQueue.cc)
-
Using uSequence (uSequence.cc)
-
Using a thread-safe random number generator (uRand.cc)
-
Using uSemaphore (uSemaphore.cc)
- Using exceptions
- Coroutine example (uCoroutine.cc)
- Example with one file (uException.cc)
- Same code, split across multiple header and implementation files:
-
Basic Administrator (Admin.cc)
Java
-
Concurrent Matrix Add (Add.java)
-
Bounded-buffer producer-consumer (BB.java)