The following examples show the use of the linked list classes:
This example application demonstrates
the use of singly linked lists. The templated TSglQue
class is used to create a singly linked list.
Download
Click on the following link to download the example: sgllist.zip
Click: browse to view the example.
Description
The example creates a singly linked list of objects of the TDigit class. This list represents a long number. An object
of class CLongNumber owns the list. The user can
edit this list using the functions defined in the CLongNumber
class. The following edit operations are possible:
Insert an object
of the TDigit
class at the start of the singly linked
list
Insert an object
of the TDigit
class at the end of the singly linked
list
Remove an object
of the TDigit
class from the end of the singly linked
list
The user can perform any of these operations by pressing
keys specified in the menu. CLongNumber
is an active
object class and handles the key press events in the CLongNumber::RunL()
function.The CLongNumber::ReadFunc()
function displays
a menu and waits for an asynchronous key press event.
An object
of the templated TSglQueIter
class is used to traverse
this linked list. The sum of all digits of the number represented
by the linked list is displayed to the user.
An object of
the CAdder class is used to traverse the CLongNumber::iNumber
list and print the sum of all digits
of the number represented by this list. The CAdder::Add()
function gets this sum.
Related APIs
CAdder
CLongNumber
TDigit
Design and implementation
Figure 1 shows the classes in the example.
Figure: Figure 1. Classes in the singly linked list example
Class summary
Build
For the emulator, the example builds
an executable called sgllist.exe
in the epoc32\release\winscw\<udeb or urel>\
folder.
See also:
This example application demonstrates
the use of doubly linked lists. The templated TDblQue
class is used create a doubly linked list.
Download
Click on the following link to download the example: dbllist.zip
Click: browse to view the example code
Description
The example creates a doubly linked list of objects of the TLetter
class. This list represents a character string.
An object of class CMyStringReverse
owns this string.
The user can edit this string using the functions defined in the CMyStringReverse
class. The following edit operations are
possible:
The user can perform either of these operations by pressing
keys specified in the menu. CMyStringReverse
is an
active object class and handles key press events in the CMyStringReverse::RunL()
function. The CMyStringReverse::ReadFunc()
function
displays a menu and waits for an asynchronous key press event.
The CMyStringReverse
class has a doubly linked
list iterator, iIteratorString
. The iIteratorString
object iterates through the list iString
from start
to end to print the string reversed.
Design and implementation
Figure 2 shows the classes in the example.
Figure: Figure 2. Classes in the doubly linked list example
Class summary
TDblQue
- A templated class that provides
the behaviour for managing a doubly linked list.
Build
For the emulator, the example builds
an executable called dbllist.exe
in the epoc32\release\winscw\<udeb or urel>\
folder.
See also
Example code
This example application demonstrates the
use of the delta queue. The templated TDeltaQue
class is used create a delta queue.
Download
Click on the following link to download the example: deltaque.zip
Click: browse to view the example code.
Description
The example creates an object of the CTimerEntry
class. This is a CTimer
derived
class. An object of this class generates timer events by using the CTimer::After()
function. The data member of this class, iQueue
is a delta list. The offset value of each node in
this list is the tick count after each timer event. The CTimerEntry::Arbitrator()
function decides the action to be performed for each event generated
by the timer. It either adds tick counts to the list or removes elements
from the list based on the state of the queue.
Related APIs
CTimer
- Base class for a timer active object.
Design and implementation
Figure 3 shows the classes of the example.
Figure: Figure 3. Classes of the delta queue example
Class summary
Build
For the emulator, the example builds
an executable called deltaque.exe
in the epoc32\release\winscw\<udeb or urel>\
folder.