|
Container classes
|
|
|
Generic-Home
Product infos Features: Data structures Smart-Cursor Download & Test |
Container classes are used to store groups of objects. On a conceptual level several basic types of containers can be identified, e.g. ordered or sorted collections, maps and queues. Generic++ allows you to use any of those abstractions without having to decide about the concrete implementation immediately. The data structure to be used is determined at the place of the declaration of the container object. The interface of container objects is independent from its implementation. This gives you the freedom to start with a standard implementation and switch the data structure to be used by just changing the declaration statement, whenever you think that this is advantageous for your applicaion. The following example shows, how easy you can sort a text file line by line: main()
{
G_String line; // Dynamic line buffer
G_SORTCLTN(G_String) lines; // Sorted container object
while (getline(cin, line))
lines.add(line);
GCursor<G_String> cursor(lines); // Enumeration cursor
G_String *pLine; // Pointer to current line
// Sorted output
The cursor used in the example is a "Smart Cursor". Follow the link to learn more about this useful feature. An Overview over all available implementation data structures can be found on the page "Plugable Data Structures". Feature overview: next page |