comparison tango/tango/util/collection/model/MapView.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: MapView.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.MapView;
16
17 private import tango.util.collection.model.View,
18 tango.util.collection.model.GuardIterator;
19
20
21 /**
22 *
23 * Maps maintain keyed elements. Any kind of Object
24 * may serve as a key for an element.
25 *
26 *
27 author: Doug Lea
28 * @version 0.93
29 *
30 * <P> For an introduction to this package see <A HREF="index.html"> Overview </A>.
31 **/
32
33
34 public interface MapView(K, V) : View!(V)
35 {
36 /**
37 * Report whether the MapT COULD include k as a key
38 * Always returns false if k is null
39 **/
40
41 public bool allowsKey(K key);
42
43 /**
44 * Report whether there exists any element with Key key.
45 * Returns: true if there is such an element
46 **/
47
48 public bool containsKey(K key);
49
50 /**
51 * Report whether there exists a (key, value) pair
52 * Returns: true if there is such an element
53 **/
54
55 public bool containsPair(K key, V value);
56
57
58 /**
59 * Return an enumeration that may be used to traverse through
60 * the keys (not elements) of the collection. The corresponding
61 * elements can be looked at by using at(k) for each key k. For example:
62 * <PRE>
63 * Iterator keys = amap.keys();
64 * while (keys.more()) {
65 * K key = keys.get();
66 * T value = amap.get(key)
67 * // ...
68 * }
69 * </PRE>
70 * Returns: the enumeration
71 **/
72
73 public PairIterator!(K, V) keys();
74
75 /**
76 traverse the collection content. This is cheaper than using an
77 iterator since there is no creation cost involved.
78 **/
79
80 int opApply (int delegate (inout K key, inout V value) dg);
81
82 /**
83 * Return the element associated with Key key.
84 * @param key a key
85 * Returns: element such that contains(key, element)
86 * Throws: NoSuchElementException if !containsKey(key)
87 **/
88
89 public V get(K key);
90 public alias get opIndex;
91
92 /**
93 * Return the element associated with Key key.
94 * @param key a key
95 * Returns: whether the key is contained or not
96 **/
97
98 public bool get(K key, inout V element);
99
100
101 /**
102 * Return a key associated with element. There may be any
103 * number of keys associated with any element, but this returns only
104 * one of them (any arbitrary one), or false if no such key exists.
105 * @param key, a place to return a located key
106 * @param element, a value to try to find a key for.
107 * Returns: true where value is found; false otherwise
108 **/
109
110 public bool keyOf(inout K key, V value);
111 }
112