|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||
com.sas.collection.OrderedListCollection
public class OrderedListCollection
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
,
which uses an specialized array implementation.
OrderedCollection
| 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 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 |
|---|
protected transient com.sas.collection.OrderedListCollection.Node items
| Constructor Detail |
|---|
public OrderedListCollection()
public OrderedListCollection(java.lang.String data)
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.
java.lang.IllegalArgumentException - if the data string
is invalid| Method Detail |
|---|
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
public void add(java.lang.Object item)
add in interface CollectionInterfaceitem - an object to add to this collection
public void add(java.lang.Object item,
int index)
add in interface OrderedCollectionInterfaceitem - 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.
java.lang.IndexOutOfBoundsException - if index
is not in the range [0, count()].
public void addItems(java.util.Enumeration items,
int index)
targetCollection.addItems(otherCollection.getItems()).
addItems in interface OrderedCollectionInterfaceitems - an enumeration of items to add to this collectionindex - Insert the objects starting before the indexed item. The
first of the newly inserted item can be accessed by get(index)
afterwards.
java.lang.ClassCastException - In some implementations,
the objects that are stored may be restricted to a particular
type (such as String).public void addItems(java.util.Enumeration items)
targetCollection.addItems(otherCollection.getItems()).
addItems in interface CollectionInterfaceitems - an Enumeration of items to add to this collection
java.lang.ClassCastException - In some implementations,
the objects that are stored may be restricted to a particular
type (such as String).public void removeAll()
removeAll in interface CollectionInterfacepublic boolean contains(java.lang.Object item)
contains in interface StaticCollectionInterfacecontains in class BaseCollectionitem - the item to search for
true if and only the item existsStaticCollectionInterface.contains(java.lang.Object)public int count()
count in interface com.sas.util.Countablecount in class BaseCollectionpublic void dumpComponent()
dumpComponent in interface ComponentInterfacedumpComponent in class ComponentComponentInterface.dumpComponent()public boolean equals(StaticOrderedCollectionInterface orderedCollection)
Object.equals(Object)
equals method is used to compare collection items.
equals in interface StaticOrderedCollectionInterfaceorderedCollection - Another ordered collection to be compared to.
true if the collection havs the same contents, false otherwise.public boolean equals(java.lang.Object obj)
StaticOrderedCollectionInterface,
compare the collection contents for equality as well.
equals in class java.lang.Objectobj - an object to compare to.
equals(StaticOrderedCollectionInterface)public java.lang.Object get(int index)
get in interface IndexedGetInterfaceindex - The position of the item, zero-based indexing.
java.lang.IndexOutOfBoundsException - if index
is not in the range [0, count()-1].
public int getIndex(java.lang.Object item,
int startIndex)
getIndex in interface StaticOrderedCollectionInterfaceitem - item to search forstartIndex - the position where the search should start
java.lang.IndexOutOfBoundsException - if startIndex is not
in the range [0..count()-1]
public java.util.Enumeration getItems(int start,
int end)
getItems in interface StaticOrderedCollectionInterfacestart - 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.
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()]public java.util.Enumeration getItems()
getItems in interface com.sas.util.EnumerablegetItems in class BaseCollectionEnumerable.getItems()
public int getLastIndex(java.lang.Object item,
int startIndex)
getLastIndex in interface StaticOrderedCollectionInterfaceitem - the item to search forstartIndex - the position where the search should start
java.lang.IndexOutOfBoundsException - if the startIndex
is not in the range [0,count()-1]public boolean remove(java.lang.Object item)
remove in interface CollectionInterfaceitem - the item to remove
true if item removed, false if not.public int removeAll(java.lang.Object item)
removeAll in interface CollectionInterfaceitem - the item to remove
public java.lang.Object removeAt(int index)
removeAt in interface OrderedCollectionInterfacethe - position of the item, zero-based indexing.
java.lang.IndexOutOfBoundsException - if index
is not in the range [0, count()-1].
public void set(int index,
java.lang.Object item)
set in interface OrderedCollectionInterfaceset in interface IndexedSetInterfaceindex - The position where the new item will be placed.item - the object to be added to this ordered collection
java.lang.IndexOutOfBoundsException - if index
is not in the range [0, count()-1].
public void append(int index,
java.lang.Object item)
index+1 items,
perform a setSize(index+1) first. Then perform a
set(index, item).
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 collectionpublic void setSize(int newSize)
null.
setSize in interface OrderedCollectionInterfacesize - The new size of this collection
java.lang.IndexOutOfBoundsException - if newSize is less than zero.public void sort(com.sas.util.Comparator comparator)
sort in interface Sortablecomparator - An instance of Comparator which provides a
Comparator.compare(Object,Object) function.Comparator
public void sort(com.sas.util.Comparator comparator,
int start,
int end)
sort in interface Sortablecomparator - 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 sortend - sort the items between start and (end-1)Comparator
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in interface CollectionInterfaceclone in interface OrderedCollectionInterfaceclone in interface StaticCollectionInterfaceclone in interface StaticOrderedCollectionInterfaceclone in interface com.sas.PublicClonableclone in class BaseCollectionjava.lang.CloneNotSupportedException - if the clone fails.
public java.lang.Object clone(com.sas.DeepCloneSupport support,
boolean deeply)
throws java.lang.CloneNotSupportedException
DeepClonable
This object and all the objects it contains
are cloned, preserving the same structure.
clone in interface com.sas.DeepClonablesupport - 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.
java.lang.CloneNotSupportedExceptionpublic java.lang.String toString()
toString in class java.lang.Object
|
| Components |
|
| |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||||