SSJ
V. 1.2.5.

umontreal.iro.lecuyer.simevents
Class LinkedListStat

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by java.util.LinkedList
                  extended by umontreal.iro.lecuyer.simevents.LinkedListStat
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, Deque, List, Queue

public class LinkedListStat
extends LinkedList

This class extends LinkedList, with statistical probes integrated in the class to provide automatic collection of statistics on the sojourn times of objects in the list and the size of the list as a function of time. The automatic statistical collection can be enabled or disabled for each list, to reduce overhead.

The iterators returned by the listIterator() method are fail-fast: if the list is structurally modified at any time after the iterator is created, in any way except through the iterator's own remove or add methods, the iterator will throw a ConcurrentModificationException.

See Also:
Serialized Form

Nested Class Summary
static interface LinkedListStat.ListIterator2
          This interface is for internal use only.
 
Constructor Summary
LinkedListStat()
          Constructs a new list, initially empty.
LinkedListStat(Collection c)
          Constructs a list containing the elements of the specified collection.
LinkedListStat(Collection c, String name)
          Constructs a new list containing the elements of the specified collection c and with name name.
LinkedListStat(String name)
          Constructs a new list with name name.
 
Method Summary
 void add(int index, Object obj)
           
 boolean add(Object obj)
           
 boolean addAll(Collection c)
           
 boolean addAll(int index, Collection c)
           
 void addFirst(Object obj)
           
 void addLast(Object obj)
           
 void clear()
           
 Object clone()
           
 boolean contains(Object obj)
           
 Object get(int index)
           
 Object getFirst()
           
 Object getLast()
           
 String getName()
          Returns the name associated to this list, or null if no name was assigned.
 int indexOf(Object obj)
           
 void initStat()
          Reinitializes the two statistical probes created by setStatCollecting (true) and makes an update for the probe on the list size.
 int lastIndexOf(Object obj)
           
 ListIterator listIterator(int index)
           
 Object remove(int index)
           
 boolean remove(Object o)
           
 Object removeFirst()
           
 Object removeLast()
           
 String report()
          Returns a string containing a statistical report on the list, provided that setStatCollecting (true) has been called before for this list.
 void setStatCollecting(boolean b)
          Starts or stops collecting statistics on this list.
 int size()
           
 Accumulate statSize()
          Returns the statistical probe on the evolution of the size of the list as a function of the simulation time.
 Tally statSojourn()
          Returns the statistical probe on the sojourn times of the objects in the list.
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 
Methods inherited from class java.util.LinkedList
descendingIterator, element, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, removeFirstOccurrence, removeLastOccurrence, set
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList
 
Methods inherited from interface java.util.Deque
iterator
 

Constructor Detail

LinkedListStat

public LinkedListStat()
Constructs a new list, initially empty.


LinkedListStat

public LinkedListStat(Collection c)
Constructs a list containing the elements of the specified collection.

Parameters:
c - collection containing elements to fill in this list with

LinkedListStat

public LinkedListStat(String name)
Constructs a new list with name name. This name can be used to identify the list in traces and reports.

Parameters:
name - name for the list object

LinkedListStat

public LinkedListStat(Collection c,
                      String name)
Constructs a new list containing the elements of the specified collection c and with name name. This name can be used to identify the list in traces and reports.

Parameters:
c - collection containing elements to fill in this list with
name - name for the list object
Method Detail

clear

public void clear()
Specified by:
clear in interface Collection
Specified by:
clear in interface List
Overrides:
clear in class LinkedList

addFirst

public void addFirst(Object obj)
Specified by:
addFirst in interface Deque
Overrides:
addFirst in class LinkedList

addLast

public void addLast(Object obj)
Specified by:
addLast in interface Deque
Overrides:
addLast in class LinkedList

add

public void add(int index,
                Object obj)
Specified by:
add in interface List
Overrides:
add in class LinkedList

add

public boolean add(Object obj)
Specified by:
add in interface Collection
Specified by:
add in interface Deque
Specified by:
add in interface List
Specified by:
add in interface Queue
Overrides:
add in class LinkedList

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Collection
Specified by:
addAll in interface List
Overrides:
addAll in class LinkedList

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface List
Overrides:
addAll in class LinkedList

getFirst

public Object getFirst()
Specified by:
getFirst in interface Deque
Overrides:
getFirst in class LinkedList

getLast

public Object getLast()
Specified by:
getLast in interface Deque
Overrides:
getLast in class LinkedList

get

public Object get(int index)
Specified by:
get in interface List
Overrides:
get in class LinkedList

contains

public boolean contains(Object obj)
Specified by:
contains in interface Collection
Specified by:
contains in interface Deque
Specified by:
contains in interface List
Overrides:
contains in class LinkedList

size

public int size()
Specified by:
size in interface Collection
Specified by:
size in interface Deque
Specified by:
size in interface List
Overrides:
size in class LinkedList

removeFirst

public Object removeFirst()
Specified by:
removeFirst in interface Deque
Overrides:
removeFirst in class LinkedList

removeLast

public Object removeLast()
Specified by:
removeLast in interface Deque
Overrides:
removeLast in class LinkedList

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection
Specified by:
remove in interface Deque
Specified by:
remove in interface List
Overrides:
remove in class LinkedList

remove

public Object remove(int index)
Specified by:
remove in interface List
Overrides:
remove in class LinkedList

indexOf

public int indexOf(Object obj)
Specified by:
indexOf in interface List
Overrides:
indexOf in class LinkedList

lastIndexOf

public int lastIndexOf(Object obj)
Specified by:
lastIndexOf in interface List
Overrides:
lastIndexOf in class LinkedList

clone

public Object clone()
Overrides:
clone in class LinkedList

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List
Overrides:
toArray in class LinkedList

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List
Overrides:
toArray in class LinkedList

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List
Overrides:
listIterator in class LinkedList

setStatCollecting

public void setStatCollecting(boolean b)
Starts or stops collecting statistics on this list. If the statistical collection is turned ON, the method creates two statistical probes if they do not exist yet. The first one, of the class Accumulate, measures the evolution of the size of the list as a function of time. It can be accessed by the method statSize. The second one, of the class Tally, and accessible via statSojourn, samples the sojourn times in the list of the objects removed during the observation period, i.e., between the last initialization time of this statistical probe and the current time. The method automatically calls initStat to initialize these two probes. When this method is used, it is normally invoked immediately after calling the constructor of the list.

Throws:
IllegalStateException - if the statistical collection is in the same state as the caller requires

initStat

public void initStat()
Reinitializes the two statistical probes created by setStatCollecting (true) and makes an update for the probe on the list size.

Throws:
IllegalStateException - if the statistical collection is disabled

statSize

public Accumulate statSize()
Returns the statistical probe on the evolution of the size of the list as a function of the simulation time. This probe exists only if setStatCollecting (true) has been called for this list.

Returns:
the statistical probe on the evolution of the size of the list

statSojourn

public Tally statSojourn()
Returns the statistical probe on the sojourn times of the objects in the list. This probe exists only if setStatCollecting (true) has been called for this list.

Returns:
the statistical probe for the sojourn times in the list

report

public String report()
Returns a string containing a statistical report on the list, provided that setStatCollecting (true) has been called before for this list. Even If setStatCollecting was called with false afterward, the report will be made for the collected observations. If the probes do not exist, i.e., setStatCollecting was never called for this object, an illegal state exception will be thrown.

Returns:
a statistical report, represented as a string
Throws:
IllegalStateException - if no statistical probes exist

getName

public String getName()
Returns the name associated to this list, or null if no name was assigned.

Returns:
the name associated to this list

SSJ
V. 1.2.5.

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.