Debian Codegraph @

net/sf/saxon/ma/trie/ImmutableMap.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2012 Michael Froh.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.ma.trie;
9
10 import java.util.Iterator;
11
12 // Original author: Michael Froh (published on Github). Released under MPL 2.0
13 // by Saxonica Limited with permission from the author
14
15
16 public interface ImmutableMap<K, V> {
17 /**
18 * Add a new entry to the map. If an entry already exists with the
19 * given key, the returned map will contain this entry, but not the
20 * existing entry.
21 *
22 * @param key the key to use to retrieve this item
23 * @param value the value stored for this item
24 * @return a new map with this item added
25 */
26 ImmutableMap<K, V> put(K key, V value);
27
28 /**
29 * Remove an entry from the map. If no entry exists with the given
30 * key, the returned map will have identical contents to the original
31 * map (and may, in fact, be the original map itself).
32 *
33 * @param key the key for the entry to remove
34 * @return a new map with the entry with the given key removed (or
35 * a map with the original contents if no entry was found
36 * for the given key).
37 */
38 ImmutableMap<K, V> remove(K key);
39
40 /**
41 * Retrieve a stored value from the map based on the key for the
42 * associated entry. If no entry exists with the given key, we
43 * return None.
44 *
45 * @param key the key for the entry to retrieve
46 * @return Some(value) if an entry exists with the given key, or
47 * None if no entry with the given key was found.
48 */
49 V get(K key);
50
51 /**
52 * Iterate over the entries in the map
53 * @return an iterator over the key-value pairs held in the map
54 */
55
56 public Iterator<Tuple2<K, V>> iterator();
57 }