001: /*
002: * $Id: HashlistIterator.java,v 1.2 2002/09/16 08:05:03 jkl Exp $
003: *
004: * Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
005: *
006: * Use is subject to license terms, as defined in
007: * Anvil Sofware License, Version 1.1. See LICENSE
008: * file, or http://njet.org/license-1.1.txt
009: */
010: package anvil.java.util;
011:
012: import java.util.Iterator;
013: import java.util.ListIterator;
014:
015: /**
016: *
017: * A <code>Hashlist</code> iterator class.
018: * Sample code for iterating through <code>Hashlist</code>:
019: *
020: * <pre>
021: * HashArray hash;
022: *
023: * //...
024: *
025: * HashArrayIterator i = hash.iterator();
026: * while(i.hasNext()) {
027: * i.next();
028: * Object key = i.key();
029: * Object value = i.value();
030: * //do some operations
031: * }
032: *
033: * </pre>
034: *
035: * @see java.util.Hashlist
036: * @author Jani Lehtimäki
037: *
038: */
039: public interface HashlistIterator extends java.util.ListIterator {
040:
041: /**
042: * Moves the cursor to beginning.
043: */
044: public void start();
045:
046: /**
047: * Moves the cursor to end.
048: */
049: public void end();
050:
051: /**
052: * Checks if the current entry exists.
053: *
054: * @return <code>true</code> if this current key exists,
055: * <code>false</code> otherwise.
056: */
057: public boolean hasCurrent();
058:
059: /**
060: * Checks if the next entry exists.
061: *
062: * @return <code>true</code> if this next key exists,
063: * <code>false</code> otherwise.
064: */
065: public boolean hasNext();
066:
067: /**
068: * Checks if previous entry exists.
069: *
070: * @return <code>true</code> if this previous key exists,
071: * <code>false</code> otherwise.
072: */
073: public boolean hasPrevious();
074:
075: /**
076: * Gets the key of the current entry.
077: *
078: * @return Key of current entry or
079: * <code>null</code> if it doesn't exist.
080: */
081: public Object key();
082:
083: /**
084: * Gets the vaclue of the current entry.
085: *
086: * @return Value of current entry or
087: * <code>null</code> if it doesn't exist.
088: */
089: public Object value();
090:
091: /**
092: * Moves to cursor next entry.
093: *
094: * @return Value in the next entry
095: * or<code>null</code> if there is no next entry.
096: */
097: public Object next();
098:
099: /**
100: * Returns the index of the element that would be returned by a
101: * subsequent call to <code>next</code>.
102: *
103: * @return the index of the element that would be returned by a subsequent call to
104: * <code>next</code>, or list size if list iterator is at end of list.
105: */
106: public int nextIndex();
107:
108: /**
109: * Returns the index of the current element.
110: *
111: * @return the index of the current element .
112: */
113: public int index();
114:
115: /**
116: * Moves cursor to previous entry.
117: *
118: * @return Value in the previous entry
119: * or<code>null</code> if there is no next entry.
120: */
121: public Object previous();
122:
123: /**
124: * Returns the index of the element that would be returned by a
125: * subsequent call to <code>previous</code>.
126: *
127: * @return the index of the element that would be returned by a subsequent call to
128: * <code>previous</code>, or -1 if list iterator is at beginning of list.
129: */
130: public int previousIndex();
131:
132: /**
133: * Inserts the specified element into the list.
134: * NOT IMPLEMENTED.
135: *
136: * @param value Value to be inserted
137: */
138: public void add(Object value);
139:
140: /**
141: * Removes the current entry.
142: * NOT IMPLEMENTED.
143: */
144: public void remove();
145:
146: /**
147: * Sets the value of current entry.
148: *
149: * @param value The new value for current entry
150: */
151: public void set(Object value);
152:
153: }
|