Mercurial > projects > ldc
comparison tango/tango/util/collection/model/GuardIterator.d @ 132:1700239cab2e trunk
[svn r136] MAJOR UNSTABLE UPDATE!!!
Initial commit after moving to Tango instead of Phobos.
Lots of bugfixes...
This build is not suitable for most things.
author | lindquist |
---|---|
date | Fri, 11 Jan 2008 17:57:40 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:5825d48b27d1 | 132:1700239cab2e |
---|---|
1 /* | |
2 File: GuardIterator.d | |
3 | |
4 Originally written by Doug Lea and released into the public domain. | |
5 Thanks for the assistance and support of Sun Microsystems Labs, Agorics | |
6 Inc, Loral, and everyone contributing, testing, and using this code. | |
7 | |
8 History: | |
9 Date Who What | |
10 24Sep95 dl@cs.oswego.edu Create from collections.d working file | |
11 | |
12 */ | |
13 | |
14 | |
15 module tango.util.collection.model.GuardIterator; | |
16 | |
17 private import tango.util.collection.model.Iterator; | |
18 | |
19 /** | |
20 * | |
21 * CollectionIterator extends the standard java.util.Iterator | |
22 * interface with two additional methods. | |
23 * | |
24 author: Doug Lea | |
25 * @version 0.93 | |
26 * | |
27 * <P> For an introduction to this package see <A HREF="index.html"> Overview </A>. | |
28 * | |
29 **/ | |
30 | |
31 public interface GuardIterator(V) : Iterator!(V) | |
32 { | |
33 /** | |
34 * Return true if the collection that constructed this enumeration | |
35 * has been detectably modified since construction of this enumeration. | |
36 * Ability and precision of detection of this condition can vary | |
37 * across collection class implementations. | |
38 * more() is false whenever corrupted is true. | |
39 * | |
40 * Returns: true if detectably corrupted. | |
41 **/ | |
42 | |
43 public bool corrupted(); | |
44 | |
45 /** | |
46 * Return the number of elements in the enumeration that have | |
47 * not yet been traversed. When corrupted() is true, this | |
48 * number may (or may not) be greater than zero even if more() | |
49 * is false. Exception recovery mechanics may be able to | |
50 * use this as an indication that recovery of some sort is | |
51 * warranted. However, it is not necessarily a foolproof indication. | |
52 * <P> | |
53 * You can also use it to pack enumerations into arrays. For example: | |
54 * <PRE> | |
55 * Object arr[] = new Object[e.numberOfRemainingElement()] | |
56 * int i = 0; | |
57 * while (e.more()) arr[i++] = e.value(); | |
58 * </PRE> | |
59 * <P> | |
60 * For the converse case, | |
61 * See_Also: tango.util.collection.iterator.ArrayIterator.ArrayIterator | |
62 * Returns: the number of untraversed elements | |
63 **/ | |
64 | |
65 public uint remaining(); | |
66 } | |
67 | |
68 | |
69 public interface PairIterator(K, V) : GuardIterator!(V) | |
70 { | |
71 alias GuardIterator!(V).get get; | |
72 alias GuardIterator!(V).opApply opApply; | |
73 | |
74 public V get (inout K key); | |
75 | |
76 int opApply (int delegate (inout K key, inout V value) dg); | |
77 } | |
78 |