umontreal.iro.lecuyer.simevents
Class ListWithStat<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<OE>
-
- umontreal.iro.lecuyer.util.TransformingList<E,ListWithStat.Node<E>>
-
- umontreal.iro.lecuyer.simevents.ListWithStat<E>
-
- All Implemented Interfaces:
- java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>
- Direct Known Subclasses:
- LinkedListStat
public class ListWithStat<E> extends TransformingList<E,ListWithStat.Node<E>>
Implements a list with integrated statistical probes to provide automatic collection of statistics on the sojourn times of objects in the list and on the size of the list as a function of time given by a simulator. The automatic statistical collection can be enabled or disabled for each list, to reduce overhead. This class extendsTransformingListand transforms elements into nodes associating insertion times with elements.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classListWithStat.Node<E>Represents a node that can be part of a list with statistical collecting.
-
Constructor Summary
Constructors Constructor and Description ListWithStat(java.util.List<ListWithStat.Node<E>> nodeList)Constructs a new list with internal data structure using the default simulator and implemented by nodeList.ListWithStat(java.util.List<ListWithStat.Node<E>> nodeList, java.util.Collection<? extends E> c)Constructs a list containing the elements of the specified collection, whose elements are stored into nodeList and using the default simulator.ListWithStat(java.util.List<ListWithStat.Node<E>> nodeList, java.util.Collection<? extends E> c, java.lang.String name)Constructs a new list containing the elements of the specified collection c, with name name, internal list nodeList, and using the default simulator.ListWithStat(java.util.List<ListWithStat.Node<E>> nodeList, java.lang.String name)Constructs a new list with name name, internal list nodeList, and using the default simulator.ListWithStat(Simulator inSim, java.util.List<ListWithStat.Node<E>> nodeList)Constructs a new list with internal data structure implemented by nodeList.ListWithStat(Simulator inSim, java.util.List<ListWithStat.Node<E>> nodeList, java.util.Collection<? extends E> c)Constructs a list containing the elements of the specified collection, whose elements are stored into nodeList.ListWithStat(Simulator inSim, java.util.List<ListWithStat.Node<E>> nodeList, java.util.Collection<? extends E> c, java.lang.String name)Constructs a new list containing the elements of the specified collection c, with name name, and internal list nodeList.ListWithStat(Simulator inSim, java.util.List<ListWithStat.Node<E>> nodeList, java.lang.String name)Constructs a new list with name name, and internal list nodeList.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(int index, E obj)voidclear()EconvertFromInnerType(ListWithStat.Node<E> node)Converts an element in the inner list to an element of the outer type.ListWithStat.Node<E>convertToInnerType(E element)Converts an element of the outer type to an element for the inner list.doublegetInitTime()Returns the last simulation timeinitStatwas called.java.lang.StringgetName()Returns the name associated to this list, or null if no name was assigned.booleangetStatCollecting()Returns true if the list collects statistics about its size and sojourn times of elements, and false otherwise.voidinitStat()Reinitializes the two statistical probes created bysetStatCollecting(true) and makes an update for the probe on the list size.java.util.Iterator<E>iterator()java.util.ListIterator<E>listIterator()java.util.ListIterator<E>listIterator(int index)Eremove(int index)java.lang.Stringreport()Returns a string containing a statistical report on the list, provided thatsetStatCollecting(true) has been called before for this list.Eset(int index, E element)voidsetSimulator(Simulator sim)Sets the simulator associated with this list.voidsetStatCollecting(boolean b)Starts or stops collecting statistics on this list.Simulatorsimulator()Returns the simulator associated with this list.AccumulatestatSize()Returns the statistical probe on the evolution of the size of the list as a function of the simulation time.TallystatSojourn()Returns the statistical probe on the sojourn times of the objects in the list.-
Methods inherited from class umontreal.iro.lecuyer.util.TransformingList
get, getInnerList, size
-
Methods inherited from class java.util.AbstractList
add, addAll, equals, hashCode, indexOf, lastIndexOf, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
-
-
-
Constructor Detail
-
ListWithStat
public ListWithStat(java.util.List<ListWithStat.Node<E>> nodeList)
Constructs a new list with internal data structure using the default simulator and implemented by nodeList. The given list is cleared for the constructed list to be initially empty.
-
ListWithStat
public ListWithStat(Simulator inSim, java.util.List<ListWithStat.Node<E>> nodeList)
Constructs a new list with internal data structure implemented by nodeList. The given list is cleared for the constructed list to be initially empty.- Parameters:
nodeList- the list containing the nodes
-
ListWithStat
public ListWithStat(java.util.List<ListWithStat.Node<E>> nodeList, java.util.Collection<? extends E> c)
Constructs a list containing the elements of the specified collection, whose elements are stored into nodeList and using the default simulator.- Parameters:
nodeList- the list containing the nodesc- collection containing elements to fill in this list with
-
ListWithStat
public ListWithStat(Simulator inSim, java.util.List<ListWithStat.Node<E>> nodeList, java.util.Collection<? extends E> c)
Constructs a list containing the elements of the specified collection, whose elements are stored into nodeList.- Parameters:
inSim- simulator associate to the current variablenodeList- the list containing the nodesc- collection containing elements to fill in this list with
-
ListWithStat
public ListWithStat(java.util.List<ListWithStat.Node<E>> nodeList, java.lang.String name)
Constructs a new list with name name, internal list nodeList, and using the default simulator. This name can be used to identify the list in traces and reports. The given list is cleared for the constructed list to be initially empty.- Parameters:
nodeList- the list containing the nodesname- name for the list object
-
ListWithStat
public ListWithStat(Simulator inSim, java.util.List<ListWithStat.Node<E>> nodeList, java.lang.String name)
Constructs a new list with name name, and internal list nodeList. This name can be used to identify the list in traces and reports. The given list is cleared for the constructed list to be initially empty.- Parameters:
inSim- simulator associate to the current variablenodeList- the list containing the nodesname- name for the list object
-
ListWithStat
public ListWithStat(java.util.List<ListWithStat.Node<E>> nodeList, java.util.Collection<? extends E> c, java.lang.String name)
Constructs a new list containing the elements of the specified collection c, with name name, internal list nodeList, and using the default simulator. This name can be used to identify the list in traces and reports.- Parameters:
nodeList- the list containing the nodesc- collection containing elements to fill in this list withname- name for the list object
-
ListWithStat
public ListWithStat(Simulator inSim, java.util.List<ListWithStat.Node<E>> nodeList, java.util.Collection<? extends E> c, java.lang.String name)
Constructs a new list containing the elements of the specified collection c, with name name, and internal list nodeList. This name can be used to identify the list in traces and reports.- Parameters:
inSim- simulator associate to the current variablenodeList- the list containing the nodesc- collection containing elements to fill in this list withname- name for the list object
-
-
Method Detail
-
convertFromInnerType
public E convertFromInnerType(ListWithStat.Node<E> node)
Description copied from class:TransformingListConverts an element in the inner list to an element of the outer type.- Specified by:
convertFromInnerTypein classTransformingList<E,ListWithStat.Node<E>>- Parameters:
node- the inner element.- Returns:
- the outer element.
-
convertToInnerType
public ListWithStat.Node<E> convertToInnerType(E element)
Description copied from class:TransformingListConverts an element of the outer type to an element for the inner list.- Specified by:
convertToInnerTypein classTransformingList<E,ListWithStat.Node<E>>- Parameters:
element- the outer element.- Returns:
- the inner element.
-
simulator
public Simulator simulator()
Returns the simulator associated with this list.- Returns:
- the simulator associated with this list
-
setSimulator
public void setSimulator(Simulator sim)
Sets the simulator associated with this list. This list should be cleared after this method is called.- Parameters:
sim- the simulator of this list
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Collection<E>- Specified by:
clearin interfacejava.util.List<E>- Overrides:
clearin classTransformingList<E,ListWithStat.Node<E>>
-
add
public void add(int index, E obj)- Specified by:
addin interfacejava.util.List<E>- Overrides:
addin classTransformingList<E,ListWithStat.Node<E>>
-
remove
public E remove(int index)
- Specified by:
removein interfacejava.util.List<E>- Overrides:
removein classTransformingList<E,ListWithStat.Node<E>>
-
iterator
public java.util.Iterator<E> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<E>- Specified by:
iteratorin interfacejava.util.Collection<E>- Specified by:
iteratorin interfacejava.util.List<E>- Overrides:
iteratorin classTransformingList<E,ListWithStat.Node<E>>
-
listIterator
public java.util.ListIterator<E> listIterator()
- Specified by:
listIteratorin interfacejava.util.List<E>- Overrides:
listIteratorin classTransformingList<E,ListWithStat.Node<E>>
-
listIterator
public java.util.ListIterator<E> listIterator(int index)
- Specified by:
listIteratorin interfacejava.util.List<E>- Overrides:
listIteratorin classTransformingList<E,ListWithStat.Node<E>>
-
set
public E set(int index, E element)
- Specified by:
setin interfacejava.util.List<E>- Overrides:
setin classTransformingList<E,ListWithStat.Node<E>>
-
getStatCollecting
public boolean getStatCollecting()
Returns true if the list collects statistics about its size and sojourn times of elements, and false otherwise. By default, statistical collecting is turned off.- Returns:
- the status of statistical collecting
-
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 classAccumulate, measures the evolution of the size of the list as a function of time. It can be accessed by the methodstatSize. The second one, of the classTallyand accessible viastatSojourn, 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 callsinitStatto initialize these two probes. When this method is used, it is normally invoked immediately after calling the constructor of the list.- Throws:
java.lang.IllegalStateException- if the statistical collection is in the same state as the caller requires
-
initStat
public void initStat()
Reinitializes the two statistical probes created bysetStatCollecting(true) and makes an update for the probe on the list size.- Throws:
java.lang.IllegalStateException- if the statistical collection is disabled
-
getInitTime
public double getInitTime()
Returns the last simulation timeinitStatwas called.- Returns:
- the last simulation time
initStatwas called
-
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 ifsetStatCollecting(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 ifsetStatCollecting(true) has been called for this list.- Returns:
- the statistical probe for the sojourn times in the list
-
report
public java.lang.String report()
Returns a string containing a statistical report on the list, provided thatsetStatCollecting(true) has been called before for this list. Even IfsetStatCollectingwas called with false afterward, the report will be made for the collected observations. If the probes do not exist, i.e.,setStatCollectingwas never called for this object, an illegal state exception will be thrown.- Returns:
- a statistical report, represented as a string
- Throws:
java.lang.IllegalStateException- if no statistical probes exist
-
getName
public java.lang.String getName()
Returns the name associated to this list, or null if no name was assigned.- Returns:
- the name associated to this list
-
-
DMelt 3.0 © DataMelt by jWork.ORG