|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gishur.core.BasicList | +--gishur.core.SimpleList
A SimpleList
is doubly connected list based upon BasicList
.
SimpleList
supplies a variety of methods to navigate lists,
to search for elements, for conversion and for operations on partial lists.
SimpleLists
(and all extended classes based upon it)
are doubly connected lists, able to store ListItems
.
ListItem
is an interface which is implemented by SimpleListItem
and StdListItem
and some more classes. SimpleList
mostly
uses SimpleListItems
. But it is possible to add
any object implementing ListItem
. For working properly, it
is essential that a ListItem
implements the interface-methods
correctly, this includes that it asks its Owner
-structure for
permission before performing an action.
As SimpleList
implements ControlledCloneable
, a clone()
-method
is also provided.
An empty list is constructed by calling SimpleList()
.
SimpleList(BasicList)
converts a structure based upon BasicList
into a SimpleList
. In this process, the old BasicList
-structure
will be deleted. On the other hand, SimpleList(ListItem,ListItem)
only
copies a part of another list-structure. This part is only inserted,
if it is not owned by another structure or the old Owner
allows it.
With SimpleList(Object[],int,int)
, it is possible to construct a
new SimpleList
taking the given array-elements as values.
length()
returns the number of stored elements, first()
the
first ListItem
of this list and last()
the last one.
firstKey()
returns the first ListItem's
key and
firstValue()
its value. lastKey()
and lastValue()
work the same way with the last ListItem
. If objects were added by
the standard mathods (i.e. without creating ListItems
before),
key(gishur.core.ListItem)
and value(gishur.core.ListItem)
return the same object. empty()
checks if the list contains no ListItems
. contains(ListItem)
checks in constant time, if the specified ListItem
is owned by this list and contains(Object)
searches for a ListItem
in this list whose value is the argument object.
Because of the search for the matching ListItem
, this operation takes linar time.
getIndex(ListItem)
returns this ListItem's
position index and
vice versa at(int)
returns the ListItem
at the specified index in the list.
With getValueAt(int)
and getKeyAt(int)
it is possible to get key and value
of the ListItem
at the given index position.
getDistance(ListItem,ListItem)
calculates the number of ListItems
between
the two arguments in the list. value(ListItem)
and key(ListItem)
return the
argument's value or key object.
next(ListItem)
returns the next ListItem
in the list and next(ListItem, int count)
the ListItem
which is count
steps forward in the list.
prev(ListItem)
and prev(ListItem, int)
work the same way in backward direction.
With relative(ListItem,int)
it is possible to access ListItems
in a
certain distance and the same does cyclicRelative(ListItem,int)
, but additionally it
supposes the list to be connected cyclic (the last element connected to the first).
find(Object)
respectively find(Object,ListItem)
searches the list for a
ListItem
which equals the argument. This method uses the ListItems'
equals(Object)
-method and should compare key-objects.
Besides, with findBigger(Object key,Comparitor)
and findSmaller(Object,Comparitor)
it is possible to search for ListItems
whose key objects are most
'similar' (due to the specified Comparitor
) to the argument object.
min(Comparitor)
and max(Comparitor)
return the smallest / biggest object
(due to the specified Comparitor
) in the list. Therefore, the Comparitor
should be able to compare ListItems
or even KeyValueHolders
.
Objects can be inserted at the end of the list by add(Object)
or
before any other position in the list by insert(ListItem,Object)
.
These methods impicitely create a SimpleListItem
which contains the
given object as its key. Additional methods are implemented to make
the easy insertion of Java primitive type values possible. In these
methods, an object of the wrapping class from java.lang
is
created and stored with add(Object)
. ListItems
can
be inserted by add(ListItem)
and insert(ListItem,ListItem)
.
Besides, methods for the use of a SimpleList
as a Stack
or a Queue
are provided.
With copy(gishur.core.ListItem, gishur.core.ListItem)
it is possible to copy intervals of the list,
cut(gishur.core.ListItem, gishur.core.ListItem)
cuts them and paste(gishur.core.ListItem, gishur.core.ListItem, gishur.core.ListItem)
inserts intervals.
paste(gishur.core.ListItem, gishur.core.ListItem, gishur.core.ListItem)
directly inserts the interval, if its Owner
permits it,
otherwise the interval is copied. That means that it is not necessary to
copy an interval from another list to be able to insert it into this one,
it is possible to directly insert it, which implicitely means copying in
the case that the insertion was denied by the interval's Owner
.
Several methods are supplied to convert a SimpleList
into another
structure. convertKeysToArray()
stores the key objects in an array, the
same does convertValuesToArray()
with the list's value objects.
keys()
and values()
return a java.util.Enumeration
-object
which enumerates the list's keys / values.
reverse()
inverses the lists order, cycle(int)
and cycle(ListItem)
rotate the list's order so that a specifiable ListItem
becomes the
first element. sort()
sorts the list according to the order defined
by the given Comparitor
using a Sorter
object.
This Comparitor
should be able to compare ListItems
or even
KeyValueHolders
.
The BasicList
implements the Serializable
interface. If
you want to avoid serializing, you can derive a list, which ensures, that it
contains at least one object not implementing the Serializable
interface.
For example, this could be a ListItem
.
BasicList
,
Stack
,
Queue
,
ListItem
,
SimpleListItem
,
ListView
, Serialized FormFields inherited from class gishur.core.BasicList |
ANY_ACCESS, KEY, LISTITEM, NO_ACCESS, VALUE |
Fields inherited from interface gishur.core.ControlledCloneable |
DEEP, FLAT |
Constructor Summary | |
SimpleList()
Empty constructor. |
|
SimpleList(BasicList L)
Conversion constructor. |
|
SimpleList(ListItem start,
int count)
Copy-constructor. |
|
SimpleList(ListItem start,
ListItem end)
Copy-constructor. |
|
SimpleList(java.lang.Object[] array,
int startindex,
int length)
Array-constructor. |
Method Summary | |
ListItem |
add(boolean w)
The add(gishur.core.ListItem) -method for boolean -values. |
ListItem |
add(double w)
The add(gishur.core.ListItem) -method for double -values. |
ListItem |
add(float w)
The add(gishur.core.ListItem) -method for float -values. |
ListItem |
add(int w)
The add(gishur.core.ListItem) -method for int -values. |
ListItem |
add(ListItem item)
Inserts the ListItem item at the end of the list. |
ListItem |
add(long w)
The add(gishur.core.ListItem) -method for long -values. |
ListItem |
add(java.lang.Object object)
Adds the object object to the end of the list. |
ListItem |
at(int index)
Returns the ListItem with index index . |
java.lang.Object |
bottom()
Returns the first element of the stack. |
void |
clear()
Clears the whole list. |
java.lang.Object |
clone()
Implementation of Cloneable clones the entire list by cloning the contained data-/keyobjects, if possible. |
java.lang.Object |
clone(java.util.Hashtable h,
int level)
Implementation of ControlledCloneable clones the entire list. |
int |
concat(BasicList L)
Appends BasicList L to this list. |
boolean |
contains(ListItem item)
Returns true , if ListItem item is part of this
list. |
boolean |
contains(java.lang.Object object)
Returns true , if this list contains the object object . |
java.lang.Object[] |
convertKeysToArray()
Returns the keys of this list in an array. |
java.lang.Object[] |
convertValuesToArray()
Returns the values of this list in an array. |
ListItem |
copy(ListItem start,
int count)
Copies a contiguous part of the list. |
ListItem |
copy(ListItem start,
ListItem end)
Copies a contiguous part of the list. |
int |
cut(ListItem start,
int count)
Cuts a contiguous part out of this list. |
int |
cut(ListItem start,
ListItem end)
Cuts a contiguous part out of this list. |
void |
cycle(int dist)
Rotates the list in cyclic manner for dist positions |
void |
cycle(ListItem item)
Rotates the list in cyclic manner to make item the first element.
|
ListItem |
cyclicRelative(ListItem base,
int count)
Returns the ListItem which is situated count steps
in forward direction from base (or null , if base
is not part of this list). |
java.lang.Object |
cyclicRelativeValue(ListItem base,
int count)
Returns the value of the ListItem which is situated count steps
in forward direction from base (or null , if base
is not part of this list). |
boolean |
empty()
Checks if this list is empty. |
ListItem |
find(ListItem item)
Searches for ListItem item in the list and returns
it, or null , if it could not be found.
|
ListItem |
find(java.lang.Object O)
Returns the first ListItem in this list for which equals(Object) }
returned true or null if no such ListItem has been
found. |
ListItem |
find(java.lang.Object O,
ListItem start)
Returns the first ListItem after start in this list for which equals(Object)
returned true or null if no such ListItem has been
found. |
ListItem |
findBigger(java.lang.Object key,
Comparitor comparitor)
Searches in the list for the ListItem which is the 'smallest' among those, which
are 'bigger' than key . |
ListItem |
findBigger(java.lang.Object key,
Comparitor comparitor,
ListItem start)
Searches in the list for the ListItem which is the 'smallest' among those, which
are 'bigger' than key . |
ListItem |
findClass(java.lang.Class C)
Returns the first ListItem which stores an object of
class C . |
ListItem |
findClass(java.lang.Class C,
ListItem start)
Returns the first ListItem after start which stores an object of
class C . |
ListItem |
findClass(java.lang.Class C,
ListItem start,
int i)
Returns the i -th ListItem after start which stores an object of
class C . |
ListItem |
findSmaller(java.lang.Object key,
Comparitor comparitor)
Searches in the list for the ListItem which is the 'biggest' among those, which
are 'smaller' than key . |
ListItem |
findSmaller(java.lang.Object key,
Comparitor comparitor,
ListItem start)
Searches in the list for the ListItem which is the 'biggest' among those, which
are 'smaller' than key . |
ListItem |
first()
Returns the first ListItem of this list. |
java.lang.Object |
firstKey()
Returns the first ListItem's key object.
|
java.lang.Object |
firstValue()
Returns the first ListItem's value object.
|
int |
getDistance(ListItem i,
ListItem j)
Returns the distance between the ListItems i and
j . |
int |
getIndex(ListItem i)
Computes ListItem i 's index in the list,
starting with the first stored item. |
java.lang.Object |
getKeyAt(int index)
Returns the key of the ListItem with index index . |
ListView |
getListView()
Creates and returns a ListView -object which enables complete reading-access
to the list without knowing the explicite type. |
java.lang.Object |
getValueAt(int index)
Returns the value of the ListItem with index index . |
ListItem |
insert(ListItem base,
boolean w)
The insert(gishur.core.ListItem, gishur.core.ListItem) -method for boolean -values. |
ListItem |
insert(ListItem base,
double w)
The insert(gishur.core.ListItem, gishur.core.ListItem) -method for double -values. |
ListItem |
insert(ListItem base,
float w)
The insert(gishur.core.ListItem, gishur.core.ListItem) -method for float -values. |
ListItem |
insert(ListItem base,
int w)
The insert(gishur.core.ListItem, gishur.core.ListItem) -method for int -values. |
ListItem |
insert(ListItem base,
ListItem item)
Inserts the ListItem item before base into the list.
|
ListItem |
insert(ListItem base,
long w)
The insert(gishur.core.ListItem, gishur.core.ListItem) -method for long -values. |
ListItem |
insert(ListItem base,
java.lang.Object object)
Creates a new ListItem containing object and inserts it
before base into the list. |
ListItem |
insert(ListItem base,
java.lang.Object[] array,
int startindex,
int length)
Inserts length objects stored in array -elements with indices higher than
startindex into the list before ListItem base .
|
java.lang.Object |
key(ListItem item)
Returns ListItem item 's key. |
java.util.Enumeration |
keys()
Returns an java.util.Enumerator -object enumerating the keys of this
list. |
ListItem |
last()
Returns the last ListItem of this list. |
java.lang.Object |
lastKey()
Returns the last ListItem's key object.
|
java.lang.Object |
lastValue()
Returns the last ListItem's value object.
|
int |
length()
Returns the number of stored elements in the list. |
ListItem |
max(Comparitor comparitor)
Searches for the maximal ListItem (due to comparitor ) in the
list. |
ListItem |
min(Comparitor comparitor)
Searches for the minimal ListItem (due to comparitor ) in the
list. |
void |
move(ListItem start,
int count,
ListItem base)
Moves the specified chain of this list to another position;
e.g. after the list element base . |
void |
move(ListItem start,
ListItem base)
Moves a single ListItem from its current position to the successor
of the given base element. |
void |
move(ListItem start,
ListItem end,
ListItem base)
Moves the specified chain of this list to another position;
e.g. after the list element base . |
ListItem |
next(ListItem i)
Returns the next ListItem after i of this list.
|
ListItem |
next(ListItem base,
int count)
Returns the ListItem which is situated count steps
in forward direction from base (or null , if base
is not part of this list). |
int |
paste(ListItem base,
ListItem start,
int count)
Inserts a chain of ListItems of maximal length count before
base into the list. |
int |
paste(ListItem base,
ListItem start,
ListItem end)
Inserts a chain of ListItems before base into the list.
|
java.lang.Object |
peek()
A stack-peek, works the same way like top() . |
java.lang.Object |
Peek()
A queue-peek, works the same way like firstValue() . |
java.lang.Object |
pop()
A stack-pop. |
java.lang.Object |
Pop()
Queue-pop. |
boolean |
popBoolean()
Pop for boolean -values. |
boolean |
PopBoolean()
Pop for boolean -values. |
double |
popDouble()
Pop for double -values. |
double |
PopDouble()
Pop for double -values. |
float |
popFloat()
Pop for float -values. |
float |
PopFloat()
Pop for float -values. |
int |
popInt()
Pop for int -values. |
int |
PopInt()
Pop for int -values. |
long |
popLong()
Pop for long -values. |
long |
PopLong()
Pop for long -values. |
ListItem |
prev(ListItem i)
Returns the previous ListItem to i .
|
ListItem |
prev(ListItem base,
int count)
Returns the ListItem which is situated count steps
in backward direction from base (or null , if base
is not part of this list). |
ListItem |
push(boolean b)
Push for boolean -values. |
ListItem |
push(double d)
Push for double -values. |
ListItem |
push(float f)
Push for float -values. |
ListItem |
push(int i)
Push for int -values. |
ListItem |
push(long l)
Push for long -values. |
ListItem |
push(java.lang.Object object)
Puts an object on the top of the stack, i.e. appends it to the queue. |
ListItem |
Push(java.lang.Object object)
Puts an object onto the bottom of the stack, i.e. inserts it before the first element of the list. |
ListItem |
relative(ListItem base,
int count)
Returns the ListItem which is situated count steps
in forward direction from base (or null , if base
is not part of this list). |
ListItem |
remove(ListItem item)
Removes the ListItem item from the list. |
ListItem |
remove(java.lang.Object key)
Removes the ListItem whose key is equal to key from the list.
|
void |
reverse()
Inverts the order in the list. |
void |
sort(Comparitor comparitor)
Sorts the list in ascending order using the Comparitor comparitor .
|
void |
sort(Comparitor comparitor,
short order)
Sorts the list in the order defined by the comparitor -object
either in ascending or in descending order (specified by order ).
|
java.lang.Object |
top()
Returns the last element of the stack. |
java.lang.String |
toString()
Overrides java.lang.Object.toString() . |
java.lang.Object |
value(ListItem item)
Returns ListItem item 's value. |
java.util.Enumeration |
values()
Returns an java.util.Enumerator -object enumerating the values of this
list. |
Methods inherited from class gishur.core.BasicList |
add, add, allowAccess, copy, copy, copy, cut, enumerate, equals, find, findClass, findClosest, getIndex, getListItem, getListItemArray, getListString, move, reconnect, reconnect, remove, requestAccess, reverse, storeInArray, toString, unconnect |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SimpleList()
public SimpleList(BasicList L)
L
into the created
SimpleList
.L
- BasicList
to be convertedpublic SimpleList(ListItem start, ListItem end)
start
is owned by another structure, normally a copy of it will be
inserted and the source structure remains unchanged.start
- starting element of the sequence to insertend
- last elementpublic SimpleList(ListItem start, int count)
start
is owned by another structure, normally a copy of it will be
inserted and the source structure remains unchanged.start
- starting element of the sequence to insertcount
- the length of the sequence to be insertedpublic SimpleList(java.lang.Object[] array, int startindex, int length)
array
,
beginning with element startindex
and ending with element startindex+length-1
.array
- an array of objects to store in the new liststartindex
- the index of the first element in the array to be stored in the listlength
- number of elements to storeMethod Detail |
public java.lang.String toString()
java.lang.Object.toString()
.toString
in class BasicList
Object.toString()
public java.lang.Object clone()
Cloneable
clone
in interface Cloneable
clone
in class java.lang.Object
this
object.InternalError
- - if the Object could not be cloned properlypublic java.lang.Object clone(java.util.Hashtable h, int level)
ControlledCloneable
ListItems
are cloned and connected proper.clone
in interface ControlledCloneable
clone
in class BasicList
h
- Hashtable to indicate which objects are already clonedlevel
- indicates how deep the objects should be clonedInternalError
- - if the Object could not be cloned properlyControlledCloneable
public int length()
length
in class BasicList
public boolean empty()
empty
in class BasicList
true
, if this list contains no ListItems
public ListItem first()
ListItem
of this list.first
in class BasicList
ListItem
public ListItem last()
ListItem
of this list.last
in class BasicList
ListItem
public java.lang.Object firstKey()
ListItem's
key object.
If the list is empty, a ListException
will be thrown.public java.lang.Object lastKey()
ListItem's
key object.
If the list is empty, a ListException
will be thrown.public java.lang.Object firstValue()
ListItem's
value object.
If the list is empty, a ListException
will be thrown.public java.lang.Object lastValue()
ListItem's
value object.
If the list is empty, a ListException
will be thrown.public boolean contains(ListItem item)
true
, if ListItem
item
is part of this
list. The check takes constant time.contains
in class BasicList
item
- ListItem
to search for in the listtrue
if item
is part of this listpublic boolean contains(java.lang.Object object)
true
, if this list contains the object object
.object
- the object to search for in the listtrue
if object
was found in the listpublic int getIndex(ListItem i)
ListItem
i
's index in the list,
starting with the first stored item. If i
is not
part of this list, -1 will be returned.i
- ListItem
, whose index is requestedpublic int getDistance(ListItem i, ListItem j)
ListItems
i
and
j
. A positive result means that j
can be reached
from i
by going forward, a negative result means the opposite (go
backward to reach j
from i
).
If i
or j
are not members of this list or one of
them cannot be reached from the other (?!), Integer.MAX_VALUE
will
be returned.getDistance
in class BasicList
i,j
- ListItems
, whose distance shall be computedpublic java.lang.Object key(ListItem item)
ListItem
item
's key. If item
is contained by this list, a ListException
will be thrown.item
public java.lang.Object value(ListItem item)
ListItem
item
's value. If item
is contained by this list, a ListException
will be thrown.item
public ListItem next(ListItem i)
ListItem
after i
of this list.
If i==null
, the first ListItem
will be returned.
If i
is not part of this list, null
will be
returned.i
- ListItem
of this listListItem
public ListItem next(ListItem base, int count)
ListItem
which is situated count
steps
in forward direction from base
(or null
, if base
is not part of this list). If base==null
, the search starts
at the first ListItem
in the list.base
- a ListItem
contained by this listcount
- number of steps to go forwardListItem
with a getDistance()
-value
of +count
from base
public ListItem relative(ListItem base, int count)
ListItem
which is situated count
steps
in forward direction from base
(or null
, if base
is not part of this list). If base==null
, the search starts
at the first ListItem
in the list.base
- a ListItem
contained by this listcount
- number of steps to go forwardListItem
with a getDistance()
-value
of +count
from base
public ListItem cyclicRelative(ListItem base, int count)
ListItem
which is situated count
steps
in forward direction from base
(or null
, if base
is not part of this list). This method supposes the list to be cyclic (the last ListItem
to be connected with the first). If base==null
, the search starts
at the first ListItem
in the list.base
- a ListItem
contained by this listcount
- number of steps to go forwardListItem
with a getDistance()
-value
of +count
from base
(in a cyclic traversal!)public java.lang.Object cyclicRelativeValue(ListItem base, int count)
ListItem
which is situated count
steps
in forward direction from base
(or null
, if base
is not part of this list). This method supposes the list to be cyclic (the last ListItem
to be connected with the first). If base==null
, the search starts
at the first ListItem
in the list.base
- a ListItem
contained by this listcount
- number of steps to go forwardListItem
with a getDistance()
-value
of +count
from base
(in a cyclic traversal!)public ListItem prev(ListItem base, int count)
ListItem
which is situated count
steps
in backward direction from base
(or null
, if base
is not part of this list). If base==null
, the search starts
at the first ListItem
in the list.base
- a ListItem
contained by this listcount
- number of steps to go backwardListItem
with a getDistance()
-value
of -count
from base
public ListItem prev(ListItem i)
ListItem
to i
.
If i==null
, the last ListItem
will be returned.
If i
is not part of this list, null
will be
returned.i
- ListItem
of this listListItem
public ListItem at(int index)
ListItem
with index index
.index
- the index of the requested ListItem
ListItem
with index index
public java.lang.Object getValueAt(int index)
ListItem
with index index
.index
- the index of the ListItem
whose value is requestedindex
public java.lang.Object getKeyAt(int index)
ListItem
with index index
.index
- the index of the ListItem
whose key is requestedindex
public ListItem find(ListItem item)
ListItem
item
in the list and returns
it, or null
, if it could not be found.
The search takes constant time.item
- ListItem
to search foritem
, it found, null
otherwisepublic ListItem find(java.lang.Object O)
ListItem
in this list for which equals(Object)
}
returned true
or null
if no such ListItem
has been
found. This search takes linear time.O
- object to search for in the listListItem
or null
public ListItem find(java.lang.Object O, ListItem start)
ListItem
after start
in this list for which equals(Object)
returned true
or null
if no such ListItem
has been
found. If start==null
, the search starts at the beginning of the list.
This search takes linear time.O
- object to search for in the liststart
- ListItem
where the search startsListItem
or null
public ListItem findClass(java.lang.Class C)
ListItem
which stores an object of
class C
. The seach takes linear time.C
- a class type of which the first object in the list should be foundListItem
or null
, if no such object was found
in a ListItem
of this listpublic ListItem findClass(java.lang.Class C, ListItem start)
ListItem
after start
which stores an object of
class C
. If start==null
, the search starts at the beginning
of the list. The search takes linear time.C
- a class type of which the first object in the list after start
should be foundstart
- a ListItem
in this list from which the search should startListItem
or null
, if no such object was found
in a ListItem
of this listpublic ListItem findClass(java.lang.Class C, ListItem start, int i)
i
-th ListItem
after start
which stores an object of
class C
. If start==null
, the search starts at the beginning
of the list. The search takes linear time.C
- a class type of which the i
-th object in the list after start
should be foundi
- the number+1 of objects of class C
which shall be ignored before the
next ListItem
containing an object of class C
shall be returnedstart
- a ListItem
in this list from which the search should startListItem
or null
, if no such object was found
in a ListItem
of this listpublic ListItem findBigger(java.lang.Object key, Comparitor comparitor)
ListItem
which is the 'smallest' among those, which
are 'bigger' than key
. 'Smaller' and 'bigger' are defined by comparitor
.
If key
is a ListItem
, the ListItems
are compared
directly, otherwise the key are compared. If key==null
, this method
returns the same result as max(Comparitor)
. If comparitor==null
, a
StdComparitor
will be used.key
- object to compare to the ListItems
in this listcomparitor
- a Comparitor
to compare this list's keysListItem
which is 'smaller' or equal to key
Comparitor
public ListItem findBigger(java.lang.Object key, Comparitor comparitor, ListItem start)
ListItem
which is the 'smallest' among those, which
are 'bigger' than key
. 'Smaller' and 'bigger' are defined by comparitor
.
The search starts at start
or at the first ListItem
, if start==null
.
If key
is a ListItem
, the ListItems
are compared
directly, otherwise the key are compared. If comparitor==null
, a
StdComparitor
will be used.key
- object to compare to the ListItems
in this listcomparitor
- a Comparitor
to compare this list's keysListItem
which is 'bigger' or equal to key
Comparitor
,
findBigger(Object, Comparitor)
public ListItem findSmaller(java.lang.Object key, Comparitor comparitor)
ListItem
which is the 'biggest' among those, which
are 'smaller' than key
. 'Smaller' and 'bigger' are defined by comparitor
.
If key
is a ListItem
, the ListItems
are compared
directly, otherwise the key are compared. If key==null
, this method
returns the same result as min(Comparitor)
. If comparitor==null
, a
StdComparitor
will be used.key
- object to compare to the ListItems
in this listcomparitor
- a Comparitor
to compare this list's keysListItem
which is 'bigger' or equal to key
Comparitor
public ListItem findSmaller(java.lang.Object key, Comparitor comparitor, ListItem start)
ListItem
which is the 'biggest' among those, which
are 'smaller' than key
. 'Smaller' and 'bigger' are defined by comparitor
.
The search starts at start
or at the first ListItem
, if start==null
.
If key
is a ListItem
, the ListItems
are compared
directly, otherwise the key are compared. If comparitor==null
, a
StdComparitor
will be used.key
- object to compare to the ListItems
in this listcomparitor
- a Comparitor
to compare this list's keysListItem
which is 'bigger' or equal to key
Comparitor
,
findSmaller(Object, Comparitor)
public ListItem min(Comparitor comparitor)
ListItem
(due to comparitor
) in the
list.comparitor
- a Comparitor
to compare this list's keysListItem
in this listpublic ListItem max(Comparitor comparitor)
ListItem
(due to comparitor
) in the
list.comparitor
- a Comparitor
to compare this list's keysListItem
in this listpublic ListItem add(ListItem item)
item
at the end of the list. If item
already belongs to the list, or if the owner can't be changed, a (flat) clone of the
ListItem item
will be inserted.item
- the new ListItempublic ListItem add(java.lang.Object object)
object
to the end of the list. The newly created ListItem
containing object
will be returned.object
- the object to be insertedListItem
storing object
add(ListItem)
public ListItem insert(ListItem base, ListItem item)
ListItem
item
before base
into the list.
If base==null, item
will be added to the end of the list. If base
is not part of this list, a ListException
will occur.
If item
is already part of this list or its Owner
cannot be changed,
a (flat) clone will be inserted.base
- position in the list before which item
will be inserteditem
- new ListItem
ListItem
public ListItem insert(ListItem base, java.lang.Object object)
ListItem
containing object
and inserts it
before base
into the list. If base==null
, it will be added
to the end of the list. If base
is not part of this list, a
ListException
will occur.base
- position in the list before which the new ListItem
will be insertedobject
- object to insert into the listListItem
insert(ListItem, ListItem)
public ListItem insert(ListItem base, java.lang.Object[] array, int startindex, int length)
length
objects stored in array
-elements with indices higher than
startindex
into the list before ListItem
base
.
If base==null
, the new ListItems
will be added to the
end of the list. If base
is not part of this list, a ListException
will occur.base
- position in the list before which the new ListItems
will
be insertedarray
- an array containing the objects to be insertedstartindex
- the index of the first element of array
whih will be insertedlength
- the number of elements of array
to insertListItem
public ListItem remove(ListItem item)
ListItem
item
from the list. If item==null
or item
is not part of the list, a ListException
occurs.item
- the ListItem
to removeListItem
public ListItem remove(java.lang.Object key)
ListItem
whose key is equal to key
from the list.
If key==null
, a ListException
will be thrown.key
- the key-object to search for in the listListItem
public ListItem copy(ListItem start, ListItem end)
start
to end
will be copied and a reference to the first element of this chain (the copy of start
)
will be returned.start
- the first ListItem
of the interval to copyend
- last ListItem
of the interval to copyListItem
of the copypublic ListItem copy(ListItem start, int count)
start
and its
maximal length is count
. The first element of the created copy
(the copy of start
) will be returned.start
- first ListItem
of the interval to copycount
- (max.) number of elements in the copyListItem
public int cut(ListItem start, ListItem end)
start
are still connected, but are no longer part of this list. The first removed element is
start
and the last one end
. The return value is the total number
of removed elements.start
- first ListItem
to cut out of this listend
- last ListItem
of the cut chainpublic int cut(ListItem start, int count)
start
are still connected, but are no longer part of this list. The first removed element is
start
and the maximally removed number of elements is count
.
The return value is the total number of removed elements.start
- first ListItem
to cut out of this listcount
- maximal number of cutted elementspublic int paste(ListItem base, ListItem start, ListItem end)
ListItems
before base
into the list.
The interval from start
to end
will be inserted.
If direct insertion is not possible, a copy is created and inserted. If
base==null
, the ListItems
will be added to the end
of the list. The number of inserted elements is returned.base
- position before which the new elements shall be insertedstart
- the first element of the sequence to be insertedend
- the last element to be insertedpublic int paste(ListItem base, ListItem start, int count)
ListItems
of maximal length count
before
base
into the list. The interval beginning with start
will be inserted.
If direct insertion is not possible, a copy is created and inserted. If
base==null
, the ListItems
will be added to the end
of the list. The number of inserted elements is returned.base
- position before which the new elements shall be insertedstart
- the first element of the sequence to be insertedcount
- the maximal number of elements to insertpublic int concat(BasicList L)
BasicList
L
to this list. After this operation,
list L
will be empty.L
- a BasicList
to append to this listListItems
public void move(ListItem start, ListItem base)
ListItem
from its current position to the successor
of the given base element.start
- ListItem
to move (must be !=null
)base
- ListItem
, after which it will be insertedpublic void move(ListItem start, ListItem end, ListItem base)
this
list to another position;
e.g. after the list element base
.start
- the ListItem
, where the chain starts (if
start==null
, the chain starts at the beginning of the list)end
- the ListItem
, where the chain ends (if
end==null
, the chain ends with the list)base
- the element after which the chain will be inserted (if
base==null
, the chain will be inserted at the beginning of
the list)public void move(ListItem start, int count, ListItem base)
this
list to another position;
e.g. after the list element base
.start
- the ListItem
, where the chain starts (if
start==null
, the chain starts at the beginning of the list)count
- the length of the chain (if count<0
the chain
ends with the list end)base
- the element after which the chain will be inserted (if
base==null
, the chain will be inserted at the beginning of
the list)public java.lang.Object[] convertKeysToArray()
SimpleList
was constructed
using the standard insertion-methods, convertKeysToArray()
and convertValuesToArray()
return the same array.convertValuesToArray()
public java.lang.Object[] convertValuesToArray()
SimpleList
was constructed
using the standard insertion-methods, convertKeysToArray()
and convertValuesToArray()
return the same array.convertKeysToArray()
public java.util.Enumeration keys()
java.util.Enumerator
-object enumerating the keys of this
list. If this SimpleList
was constructed using the standard insertion-methods,
keys()
and values()
return the same Enumeration
.Enumeration
enumerating the keysvalues()
public java.util.Enumeration values()
java.util.Enumerator
-object enumerating the values of this
list. If this SimpleList
was constructed using the standard insertion-methods,
keys()
and values()
return the same Enumeration
.Enumeration
enumerating the valueskeys()
public ListView getListView()
ListView
-object which enables complete reading-access
to the list without knowing the explicite type.getListView
in class BasicList
ListView
for reading-accesspublic void clear()
clear
in class BasicList
public void cycle(ListItem item)
item
the first element.
The operation takes constant timecycle
in class BasicList
item
- the ListItem
to become the first elementpublic void cycle(int dist)
dist
positionscycle
in class BasicList
dist
- number of rotation steps to performpublic void reverse()
public void sort(Comparitor comparitor, short order)
comparitor
-object
either in ascending or in descending order (specified by order
).
If comparitor==null
, a StdComparitor
is used.
The used Comparitor
should be able to compare KeyValueHolder
-objects.comparitor
- a Comparitor
to compare the list's keysorder
- the further order of the list: either Sorter.ASCENDING
or Sorter.DESCENDING
public void sort(Comparitor comparitor)
Comparitor
comparitor
.
If comparitor==null
, a StdComparitor
will be used.comparitor
- a Comparitor
to compare the list's keyspublic java.lang.Object bottom()
ListException
will be thrown.public java.lang.Object top()
ListException
will be thrown.public java.lang.Object peek()
top()
.top()
public java.lang.Object Peek()
firstValue()
.peek()
public ListItem push(java.lang.Object object)
object
- the object to storeListItem
storing object
public ListItem Push(java.lang.Object object)
object
- object to storeListItem
storing object
public java.lang.Object pop()
public java.lang.Object Pop()
public ListItem push(int i)
int
-values.i
- int
-value to pushListItem
storing this valuepush(java.lang.Object)
public ListItem push(long l)
long
-values.l
- long
-value to pushListItem
storing this valuepush(java.lang.Object)
public ListItem push(float f)
float
-values.f
- float
-value to pushListItem
storing this valuepush(java.lang.Object)
public ListItem push(double d)
double
-values.d
- double
-value to pushListItem
storing this valuepush(java.lang.Object)
public ListItem push(boolean b)
boolean
-values.b
- boolean
-value to push
return a ListItem
storing this valuepush(java.lang.Object)
public int popInt()
int
-values. If it is not possible to convert the
object on the stack into an int
, a ListException
will
be thrown.int
-valuepop()
public long popLong()
long
-values. If it is not possible to convert the
object on the stack into a long
, a ListException
will
be thrown.long
-valuepop()
public float popFloat()
float
-values. If it is not possible to convert the
object on the stack into a float
, a ListException
will
be thrown.float
-valuepop()
public double popDouble()
double
-values. If it is not possible to convert the
object on the stack into a double
, a ListException
will
be thrown.double
-valuepop()
public boolean popBoolean()
boolean
-values. If it is not possible to convert the
object on the stack into a boolean
, a ListException
will
be thrown.boolean
-valuepop()
public int PopInt()
int
-values. If it is not possible to convert the
object on the stack into an int
, a ListException
will
be thrown. In difference to the popInt()
-method, this method uses
peek()
and not top()
to get the stack's last element,
but this won't cause any difference in the result.int
-valuepop()
,
popInt()
public long PopLong()
long
-values. If it is not possible to convert the
object on the stack into a long
, a ListException
will
be thrown. In difference to the popLong()
-method, this method uses
peek()
and not top()
to get the stack's last element,
but this won't cause any difference in the result.long
-valuepop()
,
popLong()
public float PopFloat()
float
-values. If it is not possible to convert the
object on the stack into a float
, a ListException
will
be thrown. In difference to the popFloat()
-method, this method uses
peek()
and not top()
to get the stack's last element,
but this won't cause any difference in the result.float
-valuepop()
,
popFloat()
public double PopDouble()
double
-values. If it is not possible to convert the
object on the stack into a double
, a ListException
will
be thrown. In difference to the popDouble()
-method, this method uses
peek()
and not top()
to get the stack's last element,
but this won't cause any difference in the result.double
-valuepop()
,
popDouble()
public boolean PopBoolean()
boolean
-values. If it is not possible to convert the
object on the stack into a boolean
, a ListException
will
be thrown. In difference to the popBoolean()
-method, this method uses
peek()
and not top()
to get the stack's last element,
but this won't cause any difference in the result.boolean
-valuepop()
,
popBoolean()
public ListItem add(int w)
add(gishur.core.ListItem)
-method for int
-values. Creates a new ListItem
which
contains w
, adds it to the list's end and finally returns it.w
- int
-value to add to the listListItem
containing w
add(Object)
public ListItem add(long w)
add(gishur.core.ListItem)
-method for long
-values. Creates a new ListItem
which
contains w
, adds it to the list's end and finally returns it.w
- long
-value to add to the listListItem
containing w
add(Object)
public ListItem add(float w)
add(gishur.core.ListItem)
-method for float
-values. Creates a new ListItem
which
contains w
, adds it to the list's end and finally returns it.w
- float
-value to add to the listListItem
containing w
add(Object)
public ListItem add(double w)
add(gishur.core.ListItem)
-method for double
-values. Creates a new ListItem
which
contains w
, adds it to the list's end and finally returns it.w
- double
-value to add to the listListItem
containing w
add(Object)
public ListItem add(boolean w)
add(gishur.core.ListItem)
-method for boolean
-values. Creates a new ListItem
which
contains w
, adds it to the list's end and finally returns it.w
- boolean
-value to add to the listListItem
containing w
add(Object)
public ListItem insert(ListItem base, int w)
insert(gishur.core.ListItem, gishur.core.ListItem)
-method for int
-values. Creates a new ListItem
containing
w
, inserts it before item base
and finally returns it.base
- the position before which the new ListItem
will be insertedw
- int
-value to insertListItem
containing w
insert(ListItem, Object)
public ListItem insert(ListItem base, long w)
insert(gishur.core.ListItem, gishur.core.ListItem)
-method for long
-values. Creates a new ListItem
containing
w
, inserts it before item base
and finally returns it.base
- the position before which the new ListItem
will be insertedw
- long
-value to insertListItem
containing w
insert(ListItem, Object)
public ListItem insert(ListItem base, float w)
insert(gishur.core.ListItem, gishur.core.ListItem)
-method for float
-values. Creates a new ListItem
containing
w
, inserts it before item base
and finally returns it.base
- the position before which the new ListItem
will be insertedw
- float
-value to insertListItem
containing w
insert(ListItem, Object)
public ListItem insert(ListItem base, double w)
insert(gishur.core.ListItem, gishur.core.ListItem)
-method for double
-values. Creates a new ListItem
containing
w
, inserts it before item base
and finally returns it.base
- the position before which the new ListItem
will be insertedw
- double
-value to insertListItem
containing w
insert(ListItem, Object)
public ListItem insert(ListItem base, boolean w)
insert(gishur.core.ListItem, gishur.core.ListItem)
-method for boolean
-values. Creates a new ListItem
containing
w
, inserts it before item base
and finally returns it.base
- the position before which the new ListItem
will be insertedw
- boolean
-value to insertListItem
containing w
insert(ListItem, Object)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |