org.gnu.glib

Class List


public class List
extends Struct

Constructor Summary

List()
Construct a List object
List(Handle handle)
Contruct a List object using a given handle.

Method Summary

void
append(int data)
Append an element to the end of the list.
Handle
first()
Return the first element from the List.
void
free()
Release the resources associated with this object.
void
insert(int data, int position)
Insert an element at a specified location in the List.
Handle
last()
Return the last element from the List.
int
length()
Return the number of elements contained in the List.
Handle
next()
Return the next element in the List.
void
prepend(int data)
Prepend an element to the end of the list.
Handle
previous()
Return the previous element in the List.
void
remove(int data)
Remove the first instance of an element from the List.
void
removeAllInstances(int data)
Remove all instances of an element from the List.

Constructor Details

List

public List()
Construct a List object

List

public List(Handle handle)
Contruct a List object using a given handle. This constructor is used by the libraries internally to construct the object with the handle returned by a native method.

Method Details

append

public void append(int data)
Append an element to the end of the list.
Parameters:
data - The handle of the object that is being added to the List.

first

public Handle first()
Return the first element from the List. This method will also reposition the current list item to the beginning of the list.
Returns:
The first element from the List.

free

public void free()
Release the resources associated with this object.

insert

public void insert(int data,
                   int position)
Insert an element at a specified location in the List.
Parameters:
data - The handle of the object that is being added to the List.
position - The position to perform the insertion.

last

public Handle last()
Return the last element from the List. This method will also reposition the current list item to the end of the list.
Returns:
The last element from the List.

length

public int length()
Return the number of elements contained in the List.
Returns:
The number of elements in the List.

next

public Handle next()
Return the next element in the List. This method will also move the current list item forward one element.
Returns:
The next element from the List.

prepend

public void prepend(int data)
Prepend an element to the end of the list.
Parameters:
data - The handle of the object that is being added to the List.

previous

public Handle previous()
Return the previous element in the List. This method will also move the current list item backward one element.
Returns:
The previous element from the List.

remove

public void remove(int data)
Remove the first instance of an element from the List.
Parameters:
data - The item to remove from the list. If two items contain the same data only the first will be removed.

removeAllInstances

public void removeAllInstances(int data)
Remove all instances of an element from the List.
Parameters:
data - The item to remove from the List. This method will remove all instances of the object pointed to by data.