KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > trove > TIntIterator


1 ///////////////////////////////////////////////////////////////////////////////
2
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
3
//
4
// This library is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU Lesser General Public
6
// License as published by the Free Software Foundation; either
7
// version 2.1 of the License, or (at your option) any later version.
8
//
9
// This library is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU Lesser General Public
15
// License along with this program; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
///////////////////////////////////////////////////////////////////////////////
18

19 package gnu.trove;
20
21 /**
22  * Iterator for int collections.
23  *
24  * @author Eric D. Friedman
25  * @version $Id: TIntIterator.java,v 1.3 2004/11/09 15:48:46 ericdf Exp $
26  */

27
28 public class TIntIterator extends TPrimitiveIterator {
29     /** the collection on which the iterator operates */
30     private final TIntHash _hash;
31
32     /**
33      * Creates a TIntIterator for the elements in the specified collection.
34      */

35     public TIntIterator(TIntHash hash) {
36     super(hash);
37     this._hash = hash;
38     }
39
40     /**
41      * Advances the iterator to the next element in the underlying collection
42      * and returns it.
43      *
44      * @return the next int in the collection
45      * @exception NoSuchElementException if the iterator is already exhausted
46      */

47     public int next() {
48     moveToNextIndex();
49     return _hash._set[_index];
50     }
51 }// TIntIterator
52
Popular Tags