~ubuntu-branches/ubuntu/vivid/elki/vivid

« back to all changes in this revision

Viewing changes to src/de/lmu/ifi/dbs/elki/utilities/designpattern/Observers.java

  • Committer: Package Import Robot
  • Author(s): Erich Schubert
  • Date: 2012-06-02 17:47:03 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120602174703-1dxjcaak8v40xdu5
Tags: 0.5.0~beta2-1
* New upstream beta release.
* Needs GNU Trove 3, in NEW.
* Build with OpenJDK7, as OpenJDK6 complains.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
package de.lmu.ifi.dbs.elki.utilities.designpattern;
2
2
 
 
3
import java.util.ArrayList;
 
4
 
3
5
/*
4
6
 This file is part of ELKI:
5
7
 Environment for Developing KDD-Applications Supported by Index-Structures
6
8
 
7
 
 Copyright (C) 2011
 
9
 Copyright (C) 2012
8
10
 Ludwig-Maximilians-Universität München
9
11
 Lehr- und Forschungseinheit für Datenbanksysteme
10
12
 ELKI Development Team
23
25
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
26
 */
25
27
 
26
 
 
27
28
/**
28
29
 * Class to manage the observers of an instance.
29
30
 * 
30
 
 * Design note: to avoid reference cycles, this object does not keep track of its owner.
 
31
 * Design note: to avoid reference cycles, this object does not keep track of
 
32
 * its owner.
31
33
 * 
32
34
 * @author Erich Schubert
33
35
 * 
34
36
 * @apiviz.stereotype delegate
35
37
 * @apiviz.has Observer
36
38
 */
37
 
public class Observers<T> extends java.util.Vector<Observer<? super T>> {
 
39
public class Observers<T> extends ArrayList<Observer<? super T>> {
38
40
  /**
39
41
   * Serial version
40
42
   */
41
43
  private static final long serialVersionUID = 1L;
42
 
  
 
44
 
43
45
  /**
44
46
   * Constructor.
45
47
   */
46
48
  public Observers() {
47
49
    super();
48
50
  }
49
 
  
 
51
 
50
52
  /**
51
53
   * Add an observer to the object.
52
54
   * 
64
66
  public void removeObserver(Observer<? super T> o) {
65
67
    super.remove(o);
66
68
  }
67
 
  
 
69
 
68
70
  /**
69
71
   * Notify the observers of the changed object.
70
72
   * 
71
73
   * @param owner Owner of the Observers list - changed instance
72
74
   */
73
75
  public void notifyObservers(T owner) {
74
 
    for (Observer<? super T> observer : this) {
 
76
    for(Observer<? super T> observer : this) {
75
77
      observer.update(owner);
76
78
    }
77
79
  }