PageRenderTime 21ms CodeModel.GetById 17ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/java/de/jbee/lang/Map.java

http://github.com/jbee/jadamant
Java | 85 lines | 40 code | 23 blank | 22 comment | 0 complexity | fdea74aaf58dfa6e95d9ffdd7420d406 MD5 | raw file
 1package de.jbee.lang;
 2
 3import static de.jbee.lang.Order.entryKeysBy;
 4import static de.jbee.lang.Order.typeaware;
 5import de.jbee.lang.seq.UtileMapLister;
 6
 7/**
 8 * A {@linkplain Map} is a special case of {@link Multimap} where each key may just refer to one
 9 * value or in other words its a {@link Set} or {@link Entry}s where equality is given by equal
10 * keys.
11 * 
12 * @author Jan Bernitt (jan.bernitt@gmx.de)
13 */
14public interface Map<V>
15		extends Set<Map.Entry<V>>, Multimap<V> {
16
17	MapLister with = new UtileMapLister();
18
19	@Override
20	Map<V> deleteAt( int index );
21
22	@Override
23	Map<V> drop( int count );
24
25	/**
26	 * There will be one or none so we know that the {@link Map}-constraint won't be violated.
27	 */
28	@Override
29	Map<V> entriesAt( int index );
30
31	/**
32	 * In case a entry with the same key already exists the key's value is redefined and the
33	 * <code>value</code> given (and only that value) is associated with the key from now on.
34	 */
35	@Override
36	Map<V> insert( Key key, V value );
37
38	@Override
39	Map<V> insert( Map.Entry<V> e );
40
41	@Override
42	Map<V> subsequent();
43
44	@Override
45	Map<V> take( int count );
46
47	@Override
48	Map<V> tidyUp();
49
50	interface Key {
51
52		/**
53		 * The terminator is the highest unicode character existing. It is appended to the searched
54		 * prefix to find the position between the last key having the prefix and the first one that
55		 * does not.
56		 */
57		String PREFIX_TERMINATOR = "\ufffd";
58
59		String path();
60
61	}
62
63	interface NumericalKey
64			extends Key {
65
66		int code();
67	}
68
69	interface Entry<V>
70			extends Element<V> {
71
72		/**
73		 * Default order used for all {@link Map}s. The keys are sorted alphabetical.
74		 */
75		Ord<Object> ORDER = typeaware( entryKeysBy( Order.alphabetical ), Entry.class );
76
77		Key key();
78
79	}
80
81	interface MapLister {
82
83		<E> Map<E> noEntries( Ord<Object> order );
84	}
85}