Help Command: Contents of the doubly_linked_lists package
A list is a dynamic collection of list nodes. Each node stores a value
called an element. Each list can only hold one kind of element (though it
can be a universal type). The programmer can traverse forward or reverse
through the list. List positions are designated by cursors.
This package includes four new types:
containers.count_type
containers.hash_type
doubly_linked_lists.list
doubly_linked_lists.cursor
=> type fruit_string is new string
=> doubly_linked_lists.new_list( fruit, fruit_string )
=> (Assuming fruit is a new doubly_linked_lists.list variable)
=> doubly_linked_lists.append( fruit, "apple" );
=> doubly_linked_lists.append( fruit, "blueberry" )
=> doubly_linked_lists.append( fruit, "cherry" )
=> ? doubly_linked_lists.length( fruit )
3
=> ? doubly_linked_lists.first_element( fruit )
apple
=> ? doubly_linked_lists.contains( fruit, "pineapple" )
false
=> doubly_linked_lists.new_cursor( c, fruit_string )
=> (Assuming c is a new doubly_linked_lists.cursor variable)
=> doubly_linked_lists.first( fruit, c )
=> doubly_linked_lists.next( c )
=> ? doubly_linked_lists.element( c )
blueberry
Example: Using doubly_linked_lists to create a list of fruit
doubly_linked_lists.append( l, e )
Queue list element e at the end of the list.
Example
doubly_linked_lists.append( l, "zebra" )
Parameters
Param
Mode
Type
Default
Description
l
in out
doubly_linked_lists.list
required
the list
e
in
list element type
required
the element to queue
Exceptions
An exception is raised if the element is the wrong type
An exception is raised if out of memory
See Also
doubly_linked_lists.prepend
Compare With
Ada: Ada.Containers.Doubly_Linked_Lists.Append
Implementation Note
-
s := doubly_linked_lists.assemble( l [,d [,f]] )
Apply strings.image to each element in the list. Concatenate the strings together to form a new string,
separated by delimiter string d and ending with optional string f. An list will result in an empty string
(but f will be appended even if the string is empty).
Convert the string to a list of strings. Each string is deliminted by string d (default line feed) and optional string f will be removed from the end of the string before processing. An empty string will result in an empty list.
doubly_linked_lists.insert_before( l, c [, n] ) | ( l, c, e [, n] )
Insert element e before the cursor c. If no element is given, a node is inserted with an unknown element. If the cursor does not point at an element, the element is appended. If n is given, insert n copies instead of one.
Insert element e before the cursor c and position cursor c2 to the element inserted. If no element is given, a node is inserted with an unknown element. If the cursor does not point at an element, the element is appended. If n is given, insert n copies instead of one.
Move the cursor to the next element in the list. doubly_linked_lists.has_element will be false if the end of the list is reached. Moving when there is no element will not move the cursor.
Example
doubly_linked_lists.next( animal_position );
Parameters
Param
Mode
Type
Default
Description
c
in out
doubly_linked_lists.cursor
required
the cursor to move
Exceptions
-
See Also
doubly_linked_lists.previous
Compare With
Ada: Ada.Containers.Doubly_Linked_Lists.Next
Implementation Note
Ada version is a function.
doubly_linked_lists.prepend( l, e )
Push list element e on the front of the list.
Example
doubly_linked_lists.prepend( l, "albatross" )
Parameters
Param
Mode
Type
Default
Description
l
in out
doubly_linked_lists.list
required
the list
e
in
list element type
required
the element to push
Exceptions
An exception is raised if the element is the wrong type
An exception is raised if out of memory
See Also
doubly_linked_lists.append
Compare With
Ada: Ada.Containers.Doubly_Linked_Lists.Prepend
Implementation Note
-
doubly_linked_lists.previous( c )
Move the cursor to the previous element in the list. doubly_linked_lists.has_element will be false if the start of the list is reached. Moving when there is no element will not move the cursor.
Example
doubly_linked_lists.previous( animal_position );
Parameters
Param
Mode
Type
Default
Description
c
in out
doubly_linked_lists.cursor
required
the cursor to move
Exceptions
-
See Also
doubly_linked_lists.next
Compare With
Ada: Ada.Containers.Doubly_Linked_Lists.Previous
Implementation Note
Ada version is a function.
doubly_linked_lists.replace_element( l, c, e )
Replace the list element at the cursor position with e.
Move the cursor to the location of e in the list. Start from the end of the list. doubly_linked_lists.has_element will be false if the element is not found.
For (l1, c, l2), move the all the elements of l2 to list l1 before cursor c. If l1 and l2 are the same list, nothing happens. For (l1, c, l2, c2), move the element of l2 at cursor c2 before cursor c in list l1. If both lists and cursors are the same, nothing happens. For (l1, c, c2), move the element at cursor c2 in list l1 to new position c. If both cursors are the same, nothing happens.
An exception is raised if the element type is the wrong type. An exception is raised if a cursor points at no element
See Also
doubly_linked_lists.swap_links
Compare With
Ada: Ada.Containers.Doubly_Linked_Lists.Swap
Implementation Note
-
doubly_linked_lists.swap_links( l, c1, c2 )
Swap the elements at cursor c1 and c2 by swapping internal pointers. This is usually faster than doubly_linked_lists.swap but causes the cursor positions to be swapped in the list as well.