exe
Class GAIGSlist

java.lang.Object
  extended by exe.GAIGSbase
      extended by exe.GAIGSlist
All Implemented Interfaces:
GAIGSdatastr
Direct Known Subclasses:
GAIGSnewQueue, GAIGSnewStack, GAIGSqueue, GAIGSstack

public class GAIGSlist
extends GAIGSbase

GAIGSlist provides the ability to implement a linked list and also create GAIGS visualizations of its state. Use the various constructors to specify the general parameters for the list visualization, and use the toXML method to actually generate the array XML for snapshots.

Many, but not all, of the methods specified by the List interface are provided by this class.

Methods are also provided to set and get the presentation color of a list cell. A default list cell color can be set by using the appropriate constructor.

Known inheriters: GAIGSstack, GAIGSqueue.

Version:
6/20/06
Author:
Joseph Naps (original toXML code), Myles McNally (current version)

Field Summary
 
Fields inherited from interface exe.GAIGSdatastr
DEFAULT_COLOR, DEFAULT_FONT_SIZE, DEFAULT_NAME, DEFAULT_X1, DEFAULT_X2, DEFAULT_Y1, DEFAULT_Y2
 
Constructor Summary
GAIGSlist()
          Use all default values
GAIGSlist(java.lang.String name, java.lang.String color, double x1, double y1, double x2, double y2, double fontSize)
          Set all instance variables
 
Method Summary
 void add(int index, java.lang.Object v)
          Inserts the specified element at the specified position in this list.
 void add(int index, java.lang.Object v, java.lang.String c)
          Inserts the specified element at the specified position in this list with the provided color.
 boolean add(java.lang.Object v)
          Appends the specified element to the end of this list.
 boolean add(java.lang.Object v, java.lang.String c)
          Appends the specified element to the end of this list with the provided color.
 void addFirst(java.lang.Object v)
          Inserts the given element at the beginning of this list.
 void addFirst(java.lang.Object v, java.lang.String c)
          Inserts the given element at the beginning of this list with the provided color.
 void addLast(java.lang.Object v)
          Inserts the given element at the end of this list.
 void addLast(java.lang.Object v, java.lang.String c)
          Inserts the given element at the end of this list with the provided color.
 void clear()
          Removes all of the elements from this list.
 boolean contains(java.lang.Object v)
          Returns true if this list contains the specified element.
 java.lang.Object get(int index)
          Returns the element at the specified position in this list.
 java.lang.String getColor(int index)
          Returns the color of the element at the specified position in this list.
 java.lang.Object getFirst()
          Returns the first element in this list.
 java.lang.Object getLast()
          Returns the first element in this list.
 int indexOf(java.lang.Object v)
          Returns the index in this list of the first occurrence of the specified element, or -1 if the List does not contain this element.
 boolean isEmpty()
          Returns true if the list is empty.
 int lastIndexOf(java.lang.Object v)
          Returns the index in this list of the last occurrence of the specified element, or -1 if the List does not contain this element.
 java.lang.Object remove(int index)
          Removes and return the element at the specified position in this list.
 boolean remove(java.lang.Object o)
          Removes the first occurrence of the specified element in this list.
 java.lang.Object removeFirst()
          Remove and returns the first item in the list.
 java.lang.Object removeLast()
          Remove and returns the last item in the list.
 java.lang.Object set(int index, java.lang.Object v)
          Set the specified location with the element with the default color.
 java.lang.Object set(int index, java.lang.Object v, java.lang.String c)
          Set the specified location with the element with the provided color.
 void setColor(int index, java.lang.String c)
          Set the color of the element at the specified location.
 int size()
          Return the number of items in the list.
 java.lang.String toXML()
          Creates and returns GAIGS XML code for the current state of the linked list
 java.lang.String toXML(java.lang.String s)
          Creates and returns GAIGS XML code for the current state of the linear structure named by the parameter string.
 
Methods inherited from class exe.GAIGSbase
getName, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GAIGSlist

public GAIGSlist()
Use all default values


GAIGSlist

public GAIGSlist(java.lang.String name,
                 java.lang.String color,
                 double x1,
                 double y1,
                 double x2,
                 double y2,
                 double fontSize)
Set all instance variables

Parameters:
name - Display name of this structure.
color - Color for items unless locally overridden.
x1 - Left display bound.
y1 - Bottom display bound.
x2 - Top display bound.
y2 - Right display bound.
fontSize - Font size for display.
Method Detail

add

public boolean add(java.lang.Object v)
Appends the specified element to the end of this list. Default color will be used for this item.

Parameters:
v - The value to be stored.

add

public boolean add(java.lang.Object v,
                   java.lang.String c)
Appends the specified element to the end of this list with the provided color.

Parameters:
v - The value to be stored.
c - The color to be stored.

add

public void add(int index,
                java.lang.Object v)
Inserts the specified element at the specified position in this list. Default color will be used for this item.

Parameters:
v - The value to be stored.

add

public void add(int index,
                java.lang.Object v,
                java.lang.String c)
Inserts the specified element at the specified position in this list with the provided color.

Parameters:
v - The value to be stored.
c - The color to be stored.

addFirst

public void addFirst(java.lang.Object v)
Inserts the given element at the beginning of this list. Default color will be used for this item.

Parameters:
v - The value to be stored.

addFirst

public void addFirst(java.lang.Object v,
                     java.lang.String c)
Inserts the given element at the beginning of this list with the provided color.

Parameters:
v - The value to be stored.
c - The color to be stored.

addLast

public void addLast(java.lang.Object v)
Inserts the given element at the end of this list. Default color will be used for this item.

Parameters:
v - The value to be stored.

addLast

public void addLast(java.lang.Object v,
                    java.lang.String c)
Inserts the given element at the end of this list with the provided color.

Parameters:
v - The value to be stored.
c - The color to be stored.

clear

public void clear()
Removes all of the elements from this list.


contains

public boolean contains(java.lang.Object v)
Returns true if this list contains the specified element.

Parameters:
v - The value to be searched for.

get

public java.lang.Object get(int index)
Returns the element at the specified position in this list.

Parameters:
index - The location to be accessed.

getColor

public java.lang.String getColor(int index)
Returns the color of the element at the specified position in this list.

Parameters:
index - The location to be accessed.

getFirst

public java.lang.Object getFirst()
Returns the first element in this list.


getLast

public java.lang.Object getLast()
Returns the first element in this list.


indexOf

public int indexOf(java.lang.Object v)
Returns the index in this list of the first occurrence of the specified element, or -1 if the List does not contain this element.

Parameters:
v - The value to be searched for.

isEmpty

public boolean isEmpty()
Returns true if the list is empty.


lastIndexOf

public int lastIndexOf(java.lang.Object v)
Returns the index in this list of the last occurrence of the specified element, or -1 if the List does not contain this element.

Parameters:
v - The value to be searched for.

remove

public java.lang.Object remove(int index)
Removes and return the element at the specified position in this list.

Parameters:
index - The location to be accessed.

remove

public boolean remove(java.lang.Object o)
Removes the first occurrence of the specified element in this list. Return true if the item was found and removed.

Parameters:
o - The object to be removed.

removeFirst

public java.lang.Object removeFirst()
Remove and returns the first item in the list.


removeLast

public java.lang.Object removeLast()
Remove and returns the last item in the list.


set

public java.lang.Object set(int index,
                            java.lang.Object v)
Set the specified location with the element with the default color.

Parameters:
index - The location to be accessed.
v - The value to be stored.

set

public java.lang.Object set(int index,
                            java.lang.Object v,
                            java.lang.String c)
Set the specified location with the element with the provided color.

Parameters:
index - The location to be accessed.
v - The value to be stored.
c - The color to be stored.

setColor

public void setColor(int index,
                     java.lang.String c)
Set the color of the element at the specified location.

Parameters:
index - The location to be accessed.
c - The color to be stored.

size

public int size()
Return the number of items in the list.


toXML

public java.lang.String toXML()
Creates and returns GAIGS XML code for the current state of the linked list

Returns:
A String containing GAIGS XML code for the linked list

toXML

public java.lang.String toXML(java.lang.String s)
Creates and returns GAIGS XML code for the current state of the linear structure named by the parameter string.

Parameters:
s - The linear structure type name
Returns:
A String containing GAIGS XML code for the linked list