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 OrderedCollection

    com.sas.collection.OrderedCollection

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

Direct Known Subclasses:
  ColorList, DefaultFontFamilyList, FontList, KeyCollection, SelectionGroup

    public class OrderedCollection

implements OrderedCollectionInterface, com.sas.DeepClonable

An ordered collection is a collection which accesses items via consecutive integer indices. These indices range from 0 to n, where n=collection.count()-1.

An ordered collection allows insertion or deletion from anywhere in the collection. The `OrderedCollection` uses an efficient implementation that allows for contiguous insertion and deletion in constant time (whereas `java.util.Vector` will have O(n) behavior when inserting or deleting at the beginning of the Vector.) For example, inserting many items at the same location (the beginning or the end, or repeatdedly at some other fixed index) in an `OrderedCollection` is very efficient.

The `OrderedListCollection` uses a double linked list implementation. You should choose this class if you wish to do frequent inserts and deletes in a non-contiguous manner and otherwise access the items sequentially instead of randomly.

As with all collections, the `OrderedCollection` fires a `ContentsChangedEvent` when the contents changes. `OrderedCollection` implements the `ContentsChangedSource` interface, which defines methods to add and remove `ContentsChangedEvent` listeners. To allow more efficient processing of the event, `OrderedCollection` may send an instance of `com.sas.collection.CollectionChangedInfo` which provides more detailed information about the change, including which items changed (the range of indices) and how the collection was changed (i.e. items were added, removed, replaced, or reordered). If you have a view of the collection, you can use this information to more efficiently handle the change, rather than refreshing the view based on a complete refresh.

See Also:
  `OrderedListCollection`, `CollectionChangedInfo`, Serialized Form

Field Summary
`static java.lang.String` | `RB_KEY`

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

Constructor Summary
`OrderedCollection()` Default Constructor.
`OrderedCollection(int initialCapacity)` Construct an `OrderedCollection` with the specified initial capacity.
`OrderedCollection(int initialSize, int capacityIncrement)` Construct an `OrderedCollection` with the specified initial capacity.
`OrderedCollection(java.lang.Object[] array)` Construct an `OrderedCollection` which always maps to an existing array.
`OrderedCollection(java.lang.Object[] array, int capacityIncrement)` Construct an `OrderedCollection` which initially maps to an existing array.
`OrderedCollection(java.lang.String data)` Construct an `OrderedCollection` 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 this collection.
`void` | `append(int index, java.lang.Object item)` If this collection contains fewer than index+1 items, perform a setSize(index+1) first.
`void` | `apply(com.sas.util.ApplyInterface action)` Applies an action to every item in the current collection.
`java.lang.Object` | `clone()` Clone the object.
`java.lang.Object` | `clone(com.sas.DeepCloneSupport support, boolean deeply)` Clone this object using a deep copy.
`protected int` | `computeNewCapacity()` Compute the amount by which to grow this collection.
`boolean` | `contains(java.lang.Object item)` Test the existence of an object in a collection.
`int` | `count()` Returns the number of items in this collection
`void` | `dumpComponent()` Prints attribute information about the class.
`boolean` | `equals(java.lang.Object object)` Compare to another object
`boolean` | `equals(StaticOrderedCollectionInterface orderedCollection)` Compare the current items with those in another collection and tell whether the collections are identical.
`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 of the first occurrence of the item.
`java.util.Enumeration` | `getItems()` Return an enumeration of all the elements; the enumeration contains duplicates if this collection contains duplicates.
`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 index of the last occurrence of the item.
`protected void` | `moveHole(int newHolePosition)` Move the hole to a new position.
`protected void` | `moveHoleEnsureCapacity(int newHolePosition, int capacity)` Move the hole to a new location, while ensuring the resulting data vector has the specified data capacity.
`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)` Sorts the current collection in place using the provided comparison function.
`void` | `sort(com.sas.util.Comparator comparator, int start, int end)` Sorts a range of the current collection in place using the provided comparison function.
`static void` | `sort(OrderedCollectionInterface collection, com.sas.util.Comparator comparator, int start, int end)` Sorts a range of items in a collection in place using the provided comparison function.
`static int[]` | `sort(OrderedCollectionInterface collection, int algorithm, com.sas.util.Comparator comparator, int start, int end, int[] permutation)` Sorts a range of items in a collection in place using the provided comparison function.
`java.lang.Object[]` | `toArray()` Return a new array of objects containing the contents of this collection.
`static java.lang.Object` | `toArray(IndexedGetInterface collection)` Return a new array of objects containing the contents of the collection.
`java.lang.String` | `toString()` Convert this ordered collection to a single string.

Methods inherited from class com.sas.collection.BaseCollection
`addContentsChangedListener, anyContentsChangedListeners, 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.ContentsChangedSource
`addContentsChangedListener, removeContentsChangedListener`

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

Field Detail

### RB_KEY

    public static final java.lang.String RB_KEY

See Also:
  Constant Field Values

Constructor Detail

### OrderedCollection

    public OrderedCollection()

  Default Constructor. Equivalent to `OrderedCollection(8,0)`

### OrderedCollection

    public OrderedCollection(int initialCapacity)

  Construct an `OrderedCollection` with the specified initial capacity. The collection is still empty, and it may grow beyond this initial capacity. Use this constructor form if you have a good estimate of the number of items you will put in the collection. The collection will use default capacity growth, which is automatic doubling of the capacity.

  Parameters:
    `initialCapacity` - the initial capacity. Room for this many elements is initially allocated.

### OrderedCollection

    public OrderedCollection(int initialSize,
                             int capacityIncrement)

  Construct an `OrderedCollection` with the specified initial capacity. The collection is still empty, and it may grow beyond this initial capacity. Use this constructor form if you have a good estimate of the number of items you will put in the collection.

  Parameters:
    `initialCapacity` - the initial capacity. Room for this many elements is initially allocated.
    `capacityIncrement` - how much the collection should grow each time an `add` operation occurs when the collection is full. If capacityIncrement is 0, the collection will use default capacity growth, which is automatic doubling of the capacity. If capacityIncrement is negative, the collection will never exceed the initialCapacity; possibly throwing an exception if an operation such as an `add` is attempted.

### OrderedCollection

    public OrderedCollection(java.lang.Object[] array)

  Construct an `OrderedCollection` which always maps to an existing array. The collection cannot grow beyond the current array size and will always map onto the array. (Attempts to grow the array through add operations, etc., will throw exceptions.) Items in the array will be replaced with `null` if items are deleted from the collection, but there is no guarantee that items will be "compressed" towards the front; i.e. a gap may be left in the array after deleting items.

  Parameters:
    `array` - a non-`null` array of objects.

### OrderedCollection

    public OrderedCollection(java.lang.Object[] array,
                             int capacityIncrement)

  Construct an `OrderedCollection` which initially maps to an existing array. Items in the array will be replaced with `null` if items are deleted from the collection, but there is no guarantee that items will be "compressed" towards the front; i.e. a gap may be left in the array after deleting items.

  Parameters:
    `array` - a non-`null` array of objects.
    `capacityIncrement` - how to handle growth. If you add to the collection, the collection will grow by this much, effectively severing the mapping to the array, since a new array must be allocated. Use capacityIncrement == -1 to ensure the collection always maps to the array.

### OrderedCollection

    public OrderedCollection(java.lang.String data)

  Construct an `OrderedCollection` from a string of comma delimited values

  Parameters:
    `data` - a string of values, separated by commas. Booleans, character literals and numbers are recognized and parsed into appropriate `java.lang.Boolean, java.lang.Character, java.lang.Integer, java.lang.Long,` or `java.lang.Double` objects (for either the or the value); everything else is parsed into a String.
  Throws:
    `java.lang.IllegalArgumentException` - if the data string is invalid

Method Detail

### getExtendedBeanInfo

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

### computeNewCapacity

    protected int computeNewCapacity()

  Compute the amount by which to grow this collection. This is the capacityIncrement, or if capacityIncrement is 0, double the size, or if capacityIncrement is less than 0, throws an exception. Subclasses can override this to change the capacity/growth algorithms.

  Returns:
    the new internal collection array size.
  Throws:
    `java.lang.IndexOutOfBoundsExceptions` - if capacityIncrement is less than 0.

### moveHole

    protected final void moveHole(int newHolePosition)

  Move the hole to a new position. (Implementation details.)

  An `OrderedCollection` uses the buffer/hole algorithm for managing a sequence of objects which allows relativelyy efficient insertion/deletion of characters anywhere in the buffer, while maintaining O(1) access to any element. Simple array based implementations suffer in that additions/deletions anywhere but at the end are expensive, since they require shifting 1/2 the array on average, so add/remove operations are of O(n) complexity, where n == the length of the data.

  The hole algorithm takes advantage of the efficiency of adding/deleting items at the end of the array and makes it applicable anywhere. Basically, in a standard array implementation, N of M characters of an array of size M are "in use" and the remaining M-N items at the end of the array are unused and available. The hole algorithms simply moves this block of unused items, the "hole", such that it always appears after the point of the last insertion/deletion. Subsequent insertions/deletions at the same point are therefore O(1) operations.

  For example, let `'='` represent a hole in a character string. In a buffer of 8 characters representing the N=3 character string `"abc"`, the buffer actually contains `"abc====="`. The position of the hole is at location 3. So far, that's no different from the array implementation: we can delete the `'c'` or append a `'d'` pretty easily.

  However, to delete the `'b'` at position 1, we first shift the hole to immediately after the `'b'`, to yield `"ab=====c"`, then we delete `'b'`; the internal representation becomes `"a======c"`. The hole is no longer after the data but right in its midst. Note, however, that we can insert one or more items at position 1 without shifting the data: `add(1, '1'); add(2, '2'); add(3, '3')` will result in subsequent intermediate results: `"a1=====c"`, `"a12====c"`f and `"a123===c"`, with the hole shrinking and moving to the right each time. Only when we insert/delete an item at some location other than where the hole is do we incur the penalty of shifting data.

  Internally, the method ``moveHoleEnsureCapacity(int newHolePosition, int capacity)`` is the workhorse, with `moveHole(int newHolePosition)` doing a lot of work as well. `moveHole` will move the hole such that it appears after new position. This is done before deleting an item. For example, `moveHole(0)` will reuslt in `"a===123c"` and is a necessary precursor to deleting item 0, which is accomplished by simply decrementing the item count, replacing the item with the default value, and decrementing the holePosition. This is `O(1)`.

  `moveHoleEnsureCapacity(int, int)` will perform the `moveHole` operation and ensure there is enough room for an insert. It does both operations at the same time to avoid unnecessary copying of data that would otherwise be necessary if the hole were moved first (moving up to N items), then reallocating the array (moving N items again), then shifting the items (moving N items again).

  Parameters:
    `newHolePosition` - where the hole should appear. The hole appears before this item; i.e. after `moveHole(0)`, the hole is before item 0. After `moveHole(count)`, the hole is after the last item (which is at position (count - 1). This must be a value in the range [0,count] or you'll get an ArrayIndexOutOfBoundsException
  See Also:
    `moveHoleEnsureCapacity(int, int)`

### moveHoleEnsureCapacity

    protected final void moveHoleEnsureCapacity(int newHolePosition,
                                                int capacity)

  Move the hole to a new location, while ensuring the resulting data vector has the specified data capacity. (Implementation details.) `moveHoleEnsureCapacity` will perform the moveHole operation and ensure there is enough room for an insert. It does both operations at the same time to avoid unnecessary copying of data that would otherwise be necessary if the hole were moved first (moving up to N items), then reallocating the array (moving N items again), then shifting the items (moving N items again).

  Parameters:
    `newHolePosition` - where the hole should appear. This must be a value in the range [0,count] or you'll get an `ArrayIndexOutOfBoundsException` The hole appears before this item; i.e. after moveHole(0), the hole is before item 0. After moveHole(count), the hole is after the last item (which is at position (count - 1).
    `capacity` - how large you need the resulting data buffer to be.
  See Also:
    `moveHole(int)`

### add

    public void add(java.lang.Object item)

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

  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.
    `index` - 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 this collection. Note: to add the contents of another collection, use `targetCollection.addItems(otherCollection.getItems(), index);`

  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. The items are added at the end of the collection.

  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).

### apply

    public void apply(com.sas.util.ApplyInterface action)

  Applies an action to every item in the current collection. This is a general way to modify all the items in a collection. This does not send a ContentChangedEvent since this collection has not changed.

  Specified by:
    `apply` in interface `StaticCollectionInterface`
  Overrides:
    `apply` in class `BaseCollection`
  Parameters:
    `action` - An object that performs some action on another object. `action.apply(item)` is excecuted on successive items in this collection until all items have been operated on, or until the method returns `ApplyInterface.ABORT`

### removeAll

    public void removeAll()

  Remove all items from this collection. removeAll works by calling `setSize(0)`

  Specified by:
    `removeAll` in interface `CollectionInterface`

### contains

    public boolean contains(java.lang.Object item)

  Test the existence of an object in a collection.

  Specified by:
    `contains` in interface `StaticCollectionInterface`
  Overrides:
    `contains` in class `BaseCollection`
  Parameters:
    `item` - the item to search for
  Returns:
    boolean true if and only the item exists in the ordered collection.
  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 attribute information about the class.

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

### toArray

    public java.lang.Object[] toArray()

  Return a new array of objects containing the contents of this collection.

  Returns:
    an Object array; the array length will be count(). May contain `null` items. The array may have 0 length if this collection is empty.

### toArray

    public static java.lang.Object toArray(IndexedGetInterface collection)

  Return a new array of objects containing the contents of the collection.

  Parameters:
    `collection` - an object implementing the `IndexedGetInterface`
  Returns:
    an Object array; the array length == count() May contain `null` items. The array may have 0 length if this collection is empty.

### equals

    public boolean equals(StaticOrderedCollectionInterface orderedCollection)

  Compare the current items with those in another collection and tell whether the collections are identical. The ``Util.equal(java.util.Enumeration, java.util.Enumeration)`` method is used to compare collections.

  Specified by:
    `equals` in interface `StaticOrderedCollectionInterface`
  Parameters:
    `orderedCollection` - Another ordered collection to be compared to.
  Returns:
    boolean True if identical, False otherwise.

### equals

    public boolean equals(java.lang.Object object)

  Compare to another object

  Overrides:
    `equals` in class `java.lang.Object`
  Parameters:
    `object` - another object
  Returns:
    if the other object implements `StaticOrderedCollectionInterface`, return `equals((StaticOrderedCollectionInterface) other)`, else return false

### 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 of the first occurrence of the item. The search proceeds from startIndex to the end of the list; the index of the first item that matches the element is returned.

  Specified by:
    `getIndex` in interface `StaticOrderedCollectionInterface`
  Parameters:
    `element` - item to search for
    `startIndex` - the position where the search should start
  Returns:
    the zero-based index where the list item was first found, or -1 if the item is not found.
  Throws:
    `java.lang.IndexOutOfBoundsException` - if the index is not in the range `[0..count()-1]`.
    `java.lang.ClassCastException` - In some implementations, the objects that are stored may be restricted to a particular type (such as String).

### 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, zero based.
    `end` - one past the index of the last item to include in the enumeration, zero based. Note that the range of elements returned in the Enumeration does not include the enditem; this is consistent with `substring(start, end)` for example. For example, OrderedCollectionEnumeration(0, 5) will return items 0 through 4.

    Be sure to use -1 and not collection.count() if you want all remaining items, because if you use collection.count() and then add items before exhausting the enumeration, the new items will not be returned by the enumeration -- it will stop at the value of collection.count() when the enumeration was created.

  Returns:
    java.util.Enumeration an enumeration of the elements.
  Throws:
    `java.lang.IndexOutOfBoundsException` - if start is not in the range [0, count()-1], or start>end or end is not in the range [0, count()]

### getItems

    public java.util.Enumeration getItems()

  Return an enumeration of all the elements; the enumeration contains duplicates if this collection contains duplicates.

  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 index of the last occurrence of the item. The search proceeds from the startIndex to the start of the list until an item is found.

  Specified by:
    `getLastIndex` in interface `StaticOrderedCollectionInterface`
  Parameters:
    `element` - the item to search for
    `startIndex` - the position where the search should start
  Returns:
    the zero-based index of the last item matching element, or -1 if the item is not found.
  Throws:
    `java.lang.IndexOutOfBoundsException` - if the index is not in the range [0..count()-1]
    `java.lang.ClassCastException` - In some implementations, the objects that are stored may be restricted to a particular type (such as String). (a RuntimeException)

### 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. Note: This method finds the index of the object via `getIndex(Object item, int 0)` then invokes `removeAt(int index)`.

  Specified by:
    `remove` in interface `CollectionInterface`
  Parameters:
    `item` - the item to remove
  Returns:
    boolean 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:
    `index` - 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 Object 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)

  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 this ordered collection.

### setSize

    public void setSize(int newSize)

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

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

### sort

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

  Sorts a range of items in a collection in place using the provided comparison function. Use this if you wish to impement a OrderedCollectionInterface in some implementation class. This sort uses the IndexedSetInterface methods (Object get(int) and set(int, Object)) to access the items. Unlike calling the sort methods in the Sort class directly, this method will disable then enable ContentsChangedEvents if this collection also implements EventGateInterface.

  Parameters:
    `comparator` - An instance of a subclass of Comparator which provides a 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`

### sort

    public static int[] sort(OrderedCollectionInterface collection,
                             int algorithm,
                             com.sas.util.Comparator comparator,
                             int start,
                             int end,
                             int[] permutation)

  Sorts a range of items in a collection in place using the provided comparison function.

  Parameters:
    `collection` - a collection to sort
    `algorithm` - which algorithm to use? See com.sas.util.Sort
    `comparator` - An instance of a subclass of Comparator which provides a 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)
    `permutation` - an array of indexes which lists the reordering (permutation) performed by the sort. The caller should initialize the permutation array

                 int[] permutation = new int[c.count()];
                 for (int i = permutation.length-1; i >= 0; i--)
                   permutation[i] = i;

    before calling sort(), then read the results when sort is done. This sort method does not initialize but only permutes the integers. For example, permutation[start] will indicate the index in the sorted collection where the initial collection.get(start) can be found after the sort. This permutation can be used to permute (reorder) other collections. permutation.length should be at least (end - 1). The sort will only change elements permutation[start] through permutation[end - 1]
  See Also:
    `Permuter`, `Comparator`

### sort

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

  Sorts a range of 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 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`

### sort

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

  Sorts 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 compare(Object,Object) function.
  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.