25package umontreal.ssj.stat.list;
28import umontreal.ssj.stat.StatProbe;
63 private List<E> probes;
64 private List<ArrayOfObservationListener> listeners =
new ArrayList<ArrayOfObservationListener>();
65 protected boolean collect =
true;
66 protected boolean broadcast =
false;
67 protected String name;
73 probes =
new ArrayList<E>();
82 probes =
new ArrayList<E>();
110 return probes instanceof ArrayList;
121 probes = Collections.unmodifiableList(probes);
146 public void sum(
double[] s) {
147 if (s.length != size())
148 throw new IllegalArgumentException(
149 "Invalid length of the given array: given length is " + s.length +
", required length is " + size());
152 s[i++] = probe ==
null ? Double.NaN : probe.sum();
167 if (a.length != size())
168 throw new IllegalArgumentException(
169 "Invalid length of the given array: given length is " + a.length +
", required length is " + size());
172 a[i++] = probe ==
null ? Double.NaN : probe.average();
225 throw new NullPointerException();
226 if (!listeners.contains(l))
256 final int nl = listeners.size();
257 for (
int i = 0; i < nl; i++)
258 listeners.get(i).newArrayOfObservations(
this, x);
280 }
catch (CloneNotSupportedException cne) {
281 throw new IllegalStateException(
"CloneNotSupportedException for a class implementing Cloneable");
284 sa.probes =
new ArrayList<E>(probes);
288 public boolean add(E o) {
289 return probes.add(o);
292 public void add(
int index, E o) {
293 probes.add(index, o);
296 public boolean addAll(Collection<? extends E> c) {
297 return probes.addAll(c);
300 public boolean addAll(
int index, Collection<? extends E> c) {
301 return probes.addAll(index, c);
304 public void clear() {
308 public boolean contains(Object o) {
309 return probes.contains(o);
312 public boolean containsAll(Collection<?> c) {
313 return probes.containsAll(c);
316 public boolean equals(Object o) {
317 return probes.equals(o);
320 public E
get(
int index) {
321 return probes.get(index);
324 public int hashCode() {
325 return probes.hashCode();
328 public int indexOf(Object o) {
329 return probes.indexOf(o);
332 public boolean isEmpty() {
333 return probes.isEmpty();
336 public Iterator<E> iterator() {
337 return probes.iterator();
340 public int lastIndexOf(Object o) {
341 return probes.lastIndexOf(o);
344 public ListIterator<E> listIterator() {
345 return probes.listIterator();
348 public ListIterator<E> listIterator(
int index) {
349 return probes.listIterator();
352 public E
remove(
int index) {
353 return probes.remove(index);
356 public boolean remove(Object o) {
357 return probes.remove(o);
360 public boolean removeAll(Collection<?> c) {
361 return probes.removeAll(c);
364 public boolean retainAll(Collection<?> c) {
365 return probes.retainAll(c);
368 public E
set(
int index, E element) {
369 return probes.set(index, element);
373 return probes.size();
376 public List<E> subList(
int fromIndex,
int toIndex) {
377 return probes.subList(fromIndex, toIndex);
380 public Object[] toArray() {
381 return probes.toArray();
384 public <T> T[] toArray(T[] a) {
385 return probes.toArray(a);
The objects of this class are statistical probes or collectors, which are elementary devices for coll...
abstract String report()
Returns a string containing a report for this statistical collector.
void clearArrayOfObservationListeners()
Removes all observation listeners from the list of observers of this list of statistical probes.
void addArrayOfObservationListener(ArrayOfObservationListener l)
Adds the observation listener l to the list of observers of this list of statistical probes.
void setCollecting(boolean c)
Sets the status of the statistical collecting mechanism to c.
void setUnmodifiable()
Forbids any future modification to this list of statistical probes.
void setName(String name)
Sets the global name of this list to name.
String getName()
Returns the global name of this list of statistical probes.
boolean isModifiable()
Determines if this list of statistical probes is modifiable, i.e., if probes can be added or removed.
void notifyListeners(double[] x)
Notifies the observation x to all registered observers if broadcasting is ON.
String report()
Formats a report for each probe in the list of statistical probes.
void setBroadcasting(boolean b)
Sets the status of the observation broadcasting mechanism to b.
void sum(double[] s)
For each probe in the list, computes the sum by calling umontreal.ssj.stat.StatProbe....
boolean isCollecting()
Determines if this list of statistical probes is collecting values.
ListOfStatProbes()
Constructs an empty list of statistical probes.
ListOfStatProbes(String name)
Constructs an empty list of statistical probes with name name.
void init()
Initializes this list of statistical probes by calling umontreal.ssj.stat.StatProbe....
boolean isBroadcasting()
Determines if this list of statistical probes is broadcasting observations to registered observers.
void removeArrayOfObservationListener(ArrayOfObservationListener l)
Removes the observation listener l from the list of observers of this list of statistical probes.
void average(double[] a)
For each probe in this list, computes the average by calling umontreal.ssj.stat.StatProbe....
ListOfStatProbes< E > clone()
Clones this object.
Represents an object that can listen to observations broadcast by lists of statistical probes.