source: src/main/java/weka/classifiers/misc/monotone/EnumerationIterator.java @ 5

Last change on this file since 5 was 4, checked in by gnappo, 14 years ago

Import di weka.

File size: 2.9 KB
Line 
1/*
2 *    This program is free software; you can redistribute it and/or modify
3 *    it under the terms of the GNU General Public License as published by
4 *    the Free Software Foundation; either version 2 of the License, or
5 *    (at your option) any later version.
6 *
7 *    This program is distributed in the hope that it will be useful,
8 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 *    GNU General Public License for more details.
11 *
12 *    You should have received a copy of the GNU General Public License
13 *    along with this program; if not, write to the Free Software
14 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16
17/*
18 *    EnumerationIterator.java
19 *    Copyright (C) 2004 Stijn Lievens
20 *
21 */
22
23package weka.classifiers.misc.monotone;
24
25import weka.core.RevisionHandler;
26import weka.core.RevisionUtils;
27
28import java.util.Enumeration;
29import java.util.Iterator;
30import java.util.NoSuchElementException;
31
32/**
33 * Implementation of a simple wrapper class for the <code> Enumeration </code>
34 * interface.
35 * This makes it possible to use an <code> Enumeration </code> as if
36 * it were an <code> Iterator. </code>
37 * <p>
38 * This implementation is part of the master's thesis: "Studie
39 * en implementatie van instantie-gebaseerde algoritmen voor gesuperviseerd
40 * rangschikken", Stijn Lievens, Ghent University, 2004.
41 * </p>
42 *
43 * @author Stijn Lievens (stijn.lievens@ugent.be)
44 * @version $Revision: 5922 $
45 */
46public class EnumerationIterator
47  implements Iterator, RevisionHandler {
48
49  private Enumeration e;
50
51  /**
52   * Construct an <code> EnumerationIterator </code> on basis of on
53   * <code> Enumeration. </code>
54   *
55   * @param e the <code> Enumeration </code> on which the
56   * <code> Iterator </code> will be based
57   */
58  public EnumerationIterator(Enumeration e) {
59    this.e = e;
60  }
61
62  /**
63   * Returns <code> true </code> if there are more elements in the iteration.
64   *
65   * @return <code> true </code> if there are more elements in the iteration,
66   * <code> false </code> otherwise
67   */
68  final public boolean hasNext() {
69    return e.hasMoreElements();
70  }
71
72  /**
73   * Returns the next element in the iteration.
74   *
75   * @return the next element in the iteration
76   * @throws NoSuchElementException if the requested element does  not exist
77   */
78  final public Object next() throws NoSuchElementException  {
79    return e.nextElement();
80  }
81
82  /**
83   * Since the iteration is based on an enumeration, removal of elements
84   * is not supported.
85   *
86   * @throws UnsupportedOperationException every time this method is invoked
87   */
88  final public void remove() {
89    throw new UnsupportedOperationException();
90  }
91 
92  /**
93   * Returns the revision string.
94   *
95   * @return            the revision
96   */
97  public String getRevision() {
98    return RevisionUtils.extract("$Revision: 5922 $");
99  }
100}
Note: See TracBrowser for help on using the repository browser.