All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sas.collection
Class OrderedListCollection

    com.sas.collection.OrderedListCollection

All Implemented Interfaces:
  com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, CollectionInterface, com.sas.collection.ContentsChangedSource, OrderedCollectionInterface, Sortable, StaticCollectionInterface, StaticOrderedCollectionInterface, ComponentInterface, com.sas.DeepClonable, LinkPropertiesInterface, ModelInterface, com.sas.PublicClonable, com.sas.util.Countable, com.sas.util.Enumerable, com.sas.util.EventGateInterface, IndexedGetInterface, IndexedSetInterface, ViewInterface, MultipleValueEventSourceInterface, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.EventListener

    public class OrderedListCollection

implements OrderedCollectionInterface, com.sas.DeepClonable

An `OrderedListCollection` is a linked list implementation of `OrderedCollectionInterface`. An ordered collection allows easy insertion or deletion from the middle of the collection. The `OrderedListCollection` uses a double linked list implementation. You should choose this class if you wish to do frequent inserts and deletes at arbitrary and non-contiguous locations in the list and otherwise access the items sequentially instead of randomly. For example, implementing a queue or dequeue, which adds items at one end of the collection and removes items from the opposite end, will be much more efficient with an `OrderedListCollection` than with the ``OrderedCollection``, which uses an specialized array implementation.

See Also:
  Serialized Form

Field Summary
`protected com.sas.collection.OrderedListCollection.Node` | `items`

Fields inherited from class com.sas.collection.BaseCollection
`allContentsChangedListeners, mappingObject`

Constructor Summary
`OrderedListCollection()` Create an empty OrderedListCollection.
`OrderedListCollection(java.lang.String data)` Construct an OrderedListCollection from a string of comma delimited values

Method Summary
`void` | `add(java.lang.Object item)` Add an item to a collection.
`void` | `add(java.lang.Object item, int index)` Insert an item into a specific location in this collection.
`void` | `addItems(java.util.Enumeration items)` Add all elements of an enumeration to this collection.
`void` | `addItems(java.util.Enumeration items, int index)` Add all elements of an enumeration to the end of this collection.
`void` | `append(int index, java.lang.Object item)` Store an item in the collection, appending if necessary.
`java.lang.Object` | `clone()` Clone the object.
`java.lang.Object` | `clone(com.sas.DeepCloneSupport support, boolean deeply)` Clone this object using a deep copy.
`boolean` | `contains(java.lang.Object item)` Test if this collection contains an item.
`int` | `count()` Returns the number of items in this collection.
`void` | `dumpComponent()` Prints the object.
`boolean` | `equals(java.lang.Object obj)` Test if this collection equals another object.
`boolean` | `equals(StaticOrderedCollectionInterface orderedCollection)` Compare the current items with those in another collection and tell whether the collections have the same contents.
`java.lang.Object` | `get(int index)` Fetch the item at the specified index.
`static com.sas.beans.ExtendedBeanInfo` | `getExtendedBeanInfo()`
`int` | `getIndex(java.lang.Object item, int startIndex)` Returns the index associated with the item (searches forward)
`java.util.Enumeration` | `getItems()` Return an enumeration of all the elements from this collection.
`java.util.Enumeration` | `getItems(int start, int end)` Returns an enumeration of a subset of the items from a collection
`int` | `getLastIndex(java.lang.Object item, int startIndex)` Returns the last index associated with the item (searches backward)
`boolean` | `remove(java.lang.Object item)` Remove an item from this collection.
`void` | `removeAll()` Remove all items from this collection.
`int` | `removeAll(java.lang.Object item)` Remove all occurrences of an item from this collection.
`java.lang.Object` | `removeAt(int index)` Remove from this collection the item at the specified index.
`void` | `set(int index, java.lang.Object item)` Replace the item at the specified index with a new item.
`void` | `setSize(int newSize)` Set the number of items that are being held in this collection.
`void` | `sort(com.sas.util.Comparator comparator)` Sort the current collection in place using the provided comparison function.
`void` | `sort(com.sas.util.Comparator comparator, int start, int end)` Sort the current collection in place using the provided comparison function.
`java.lang.String` | `toString()` Convert this ordered collection to a single string.

Methods inherited from class com.sas.collection.BaseCollection
`addContentsChangedListener, anyContentsChangedListeners, apply, disableEvents, enableEvents, enableEvents, fireContentsChanged, map, removeContentsChangedListener, unmap`

Methods inherited from class com.sas.Component
`addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, beansIsDesignTime, beansSetDesignTime, clone, detachModel, detachView, firePropertyChange, firePropertyChange, fireVetoableChange, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getLinkInfo, getModelInterface, getRequiredInterfaces, getResources, getStringResource, getViewInterfaceSupportInfo, initialize, initializeComponent, isDesignTime, isLinked, propertyChange, queryLinks, queryLinks, refresh, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setComponentDescription, setComponentSupportInfo, setDefaultValues, setLinkInfo, setModelInterface, setRequiredInterfaces, setViewInterfaceSupportInfo, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, validateObject`

Methods inherited from interface com.sas.collection.StaticCollectionInterface
`apply`

Methods inherited from interface com.sas.collection.ContentsChangedSource
`addContentsChangedListener, removeContentsChangedListener`

Methods inherited from interface com.sas.beans.PropertyChangeSource
`addPropertyChangeListener, removePropertyChangeListener`

Field Detail

### items

    protected transient com.sas.collection.OrderedListCollection.Node items

Constructor Detail

### OrderedListCollection

    public OrderedListCollection()

  Create an empty OrderedListCollection.

### OrderedListCollection

    public OrderedListCollection(java.lang.String data)

  Construct an OrderedListCollection from a string of comma delimited values

  Parameters:
    `data` - a string of values, separated by commas. Boolean and number objects are recognized and parsed into appropriate ``Boolean`, `Integer`, `Long`,` or ``Double`` objects; everything else is parsed into a ``String`` or ``Character``.
  Throws:
    `java.lang.IllegalArgumentException` - if the data string is invalid

Method Detail

### getExtendedBeanInfo

    public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()

### add

    public void add(java.lang.Object item)

  Add an item to a collection. The item is added to the end.

  Specified by:
    `add` in interface `CollectionInterface`
  Parameters:
    `item` - an object to add to this collection

### add

    public void add(java.lang.Object item,
                    int index)

  Insert an item into a specific location in this collection. Items after the index will be shifted out of the way.

  Specified by:
    `add` in interface `OrderedCollectionInterface`
  Parameters:
    `item` - the item to add to this collection. The item may exist multiple times in this collection.
    `Insert` - the object before the indexed item. The newly inserted item can be accessed by `get(index)` afterwards.
  Throws:
    `java.lang.IndexOutOfBoundsException` - if index is not in the range `[0, count()]`.

### addItems

    public void addItems(java.util.Enumeration items,
                         int index)

  Add all elements of an enumeration to the end of this collection. Note: to add the contents of another collection, use `targetCollection.addItems(otherCollection.getItems())`.

  Specified by:
    `addItems` in interface `OrderedCollectionInterface`
  Parameters:
    `items` - an enumeration of items to add to this collection
    `index` - Insert the objects starting before the indexed item. The first of the newly inserted item can be accessed by `get(index)` afterwards.
  Throws:
    `java.lang.ClassCastException` - In some implementations, the objects that are stored may be restricted to a particular type (such as String).

### addItems

    public void addItems(java.util.Enumeration items)

  Add all elements of an enumeration to this collection. Note: to add the contents of another collection, use `targetCollection.addItems(otherCollection.getItems())`.

  Specified by:
    `addItems` in interface `CollectionInterface`
  Parameters:
    `items` - an Enumeration of items to add to this collection
  Throws:
    `java.lang.ClassCastException` - In some implementations, the objects that are stored may be restricted to a particular type (such as String).

### removeAll

    public void removeAll()

  Remove all items from this collection.

  Specified by:
    `removeAll` in interface `CollectionInterface`

### contains

    public boolean contains(java.lang.Object item)

  Test if this collection contains an item.

  Specified by:
    `contains` in interface `StaticCollectionInterface`
  Overrides:
    `contains` in class `BaseCollection`
  Parameters:
    `item` - the item to search for
  Returns:
    `true` if and only the item exists
  See Also:
    `StaticCollectionInterface.contains(java.lang.Object)`

### count

    public int count()

  Returns the number of items in this collection.

  Specified by:
    `count` in interface `com.sas.util.Countable`
  Specified by:
    `count` in class `BaseCollection`
  Returns:
    the number of items in this collection

### dumpComponent

    public void dumpComponent()

  Prints the object.

  Specified by:
    `dumpComponent` in interface `ComponentInterface`
  Overrides:
    `dumpComponent` in class `Component`
  See Also:
    `ComponentInterface.dumpComponent()`

### equals

    public boolean equals(StaticOrderedCollectionInterface orderedCollection)

  Compare the current items with those in another collection and tell whether the collections have the same contents. The `Object.equals(Object)` equals method is used to compare collection items.

  Specified by:
    `equals` in interface `StaticOrderedCollectionInterface`
  Parameters:
    `orderedCollection` - Another ordered collection to be compared to.
  Returns:
    `true` if the collection havs the same contents, `false` otherwise.

### equals

    public boolean equals(java.lang.Object obj)

  Test if this collection equals another object. If the object is a `StaticOrderedCollectionInterface`, compare the collection contents for equality as well.

  Overrides:
    `equals` in class `java.lang.Object`
  Parameters:
    `obj` - an object to compare to.
  Returns:
    true if equal, false otherwise.
  See Also:
    `equals(StaticOrderedCollectionInterface)`

### get

    public java.lang.Object get(int index)

  Fetch the item at the specified index.

  Specified by:
    `get` in interface `IndexedGetInterface`
  Parameters:
    `index` - The position of the item, zero-based indexing.
  Returns:
    the item associated with the index value
  Throws:
    `java.lang.IndexOutOfBoundsException` - if index is not in the range `[0, count()-1]`.

### getIndex

    public int getIndex(java.lang.Object item,
                        int startIndex)

  Returns the index associated with the item (searches forward)

  Specified by:
    `getIndex` in interface `StaticOrderedCollectionInterface`
  Parameters:
    `item` - item to search for
    `startIndex` - the position where the search should start
  Returns:
    the zero-based index corresponding to the item or -1 if the item is not found.
  Throws:
    `java.lang.IndexOutOfBoundsException` - if startIndex is not in the range `[0..count()-1]`

### getItems

    public java.util.Enumeration getItems(int start,
                                          int end)

  Returns an enumeration of a subset of the items from a collection

  Specified by:
    `getItems` in interface `StaticOrderedCollectionInterface`
  Parameters:
    `start` - the index of the first item.
    `end` - one more than the index of the last item. for example, `collection.getItems(0, collection.count())`; is equivalent to `collection.getItems()`, although the latter is more efficient.
  Returns:
    java.util.Enumeration an enumeration of the elements.
  Throws:
    `java.lang.IndexOutOfBoundsException` - if start is not in the range `[0, count()-1]` or if start > end, or if end is not in the range `[0, count()]`

### getItems

    public java.util.Enumeration getItems()

  Return an enumeration of all the elements from this collection.

  Specified by:
    `getItems` in interface `com.sas.util.Enumerable`
  Specified by:
    `getItems` in class `BaseCollection`
  Returns:
    java.util.Enumeration An Enumeration of this collection's contents
  See Also:
    `Enumerable.getItems()`

### getLastIndex

    public int getLastIndex(java.lang.Object item,
                            int startIndex)

  Returns the last index associated with the item (searches backward)

  Specified by:
    `getLastIndex` in interface `StaticOrderedCollectionInterface`
  Parameters:
    `item` - the item to search for
    `startIndex` - the position where the search should start
  Returns:
    the zero-based index corresponding to the last occurrence of the item at or before the startIndex or -1 if the item is not found.
  Throws:
    `java.lang.IndexOutOfBoundsException` - if the startIndex is not in the range `[0,count()-1]`

### remove

    public boolean remove(java.lang.Object item)

  Remove an item from this collection. If the item appears multiple times, only the first occurrance is removed.

  Specified by:
    `remove` in interface `CollectionInterface`
  Parameters:
    `item` - the item to remove
  Returns:
    `true` if item removed, `false` if not.

### removeAll

    public int removeAll(java.lang.Object item)

  Remove all occurrences of an item from this collection.

  Specified by:
    `removeAll` in interface `CollectionInterface`
  Parameters:
    `item` - the item to remove
  Returns:
    the number of items deleted

### removeAt

    public java.lang.Object removeAt(int index)

  Remove from this collection the item at the specified index. Items will be shifted to fill in the hole.

  Specified by:
    `removeAt` in interface `OrderedCollectionInterface`
  Parameters:
    `the` - position of the item, zero-based indexing.
  Returns:
    the object that was removed from this collection
  Throws:
    `java.lang.IndexOutOfBoundsException` - if index is not in the range `[0, count()-1]`.

### set

    public void set(int index,
                    java.lang.Object item)

  Replace the item at the specified index with a new item.

  Specified by:
    `set` in interface `OrderedCollectionInterface`
  Specified by:
    `set` in interface `IndexedSetInterface`
  Parameters:
    `index` - The position where the new item will be placed.
    `item` - the object to be added to this ordered collection
  Throws:
    `java.lang.IndexOutOfBoundsException` - if index is not in the range `[0, count()-1]`.

### append

    public void append(int index,
                       java.lang.Object item)

  Store an item in the collection, appending if necessary. If this collection contains fewer than `index+1` items, perform a `setSize(index+1)` first. Then perform a `set(index, item)`.

  Parameters:
    `index` - The position where the object will be placed. If necessary, this collection is extended to accommodate the item.
    `item` - the object to be added to the ordered collection

### setSize

    public void setSize(int newSize)

  Set the number of items that are being held in this collection. If newSize is smaller than the current collection size, then this collection is truncated to the size specified. If newSize is greater than the current collection size, then this collection's size is extended, and the new collection slots are assigned `null`.

  Specified by:
    `setSize` in interface `OrderedCollectionInterface`
  Parameters:
    `size` - The new size of this collection
  Throws:
    `java.lang.IndexOutOfBoundsException` - if newSize is less than zero.

### sort

    public void sort(com.sas.util.Comparator comparator)

  Sort the current collection in place using the provided comparison function.

  Specified by:
    `sort` in interface `Sortable`
  Parameters:
    `comparator` - An instance of Comparator which provides a `Comparator.compare(Object,Object)` function.
  See Also:
    `Comparator`

### sort

    public void sort(com.sas.util.Comparator comparator,
                     int start,
                     int end)

  Sort the current collection in place using the provided comparison function.

  Specified by:
    `sort` in interface `Sortable`
  Parameters:
    `comparator` - An instance of a subclass of Comparator which provides a `Comparator.compare(Object,Object)` function.
    `start` - the index of the first item in the range to sort
    `end` - sort the items between start and `(end-1)`
  See Also:
    `Comparator`

### clone

    public java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  Clone the object.

  Specified by:
    `clone` in interface `CollectionInterface`
  Specified by:
    `clone` in interface `OrderedCollectionInterface`
  Specified by:
    `clone` in interface `StaticCollectionInterface`
  Specified by:
    `clone` in interface `StaticOrderedCollectionInterface`
  Specified by:
    `clone` in interface `com.sas.PublicClonable`
  Overrides:
    `clone` in class `BaseCollection`
  Returns:
    a clone of this collection.
  Throws:
    `java.lang.CloneNotSupportedException` - if the clone fails.

### clone

    public java.lang.Object clone(com.sas.DeepCloneSupport support,
                                  boolean deeply)
                           throws java.lang.CloneNotSupportedException

  Clone this object using a deep copy. With this method, this class implements `DeepClonable` This object and all the objects it contains are cloned, preserving the same structure.

  Specified by:
    `clone` in interface `com.sas.DeepClonable`
  Parameters:
    `support` - a required object which keeps track of cloned objects during the deep cloning.
    `deeply` - If true, clone recursively using the deep clone support. if false, this is equivalent to a normal clone.
  Throws:
    `java.lang.CloneNotSupportedException`

### toString

    public java.lang.String toString()

  Convert this ordered collection to a single string.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    a string consisting of the comma separated values in this collection

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.