source: trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/SymbolMap.java @ 2218

Last change on this file since 2218 was 2218, checked in by pharms, 7 years ago
  • java doc issues removal
File size: 4.9 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.usageprofiles;
16
17import java.io.Serializable;
18import java.util.Collection;
19
20/**
21 * <p>
22 * This interface defines a data structure for holding symbols. Its implementations can be used to
23 * improve the performance of a trie by tuning its internal symbol storage management.
24 * </p>
25 * <p>
26 * The interface is called a map, although it is not necessarily. It may contain the same element
27 * as separate keys. This is allowed for performance improvements. If it is required to really
28 * assure, that a key exists only once, then each call to the {@link #addSymbol(Object, Object)}
29 * method should be done only, if the {@link #containsSymbol(Object)} method for the same symbol
30 * returns false.
31 * </p>
32 * <p>
33 * Mapping a symbol to the value null is possible. In this case {@link #getValue(Object)} returns
34 * null for the symbol. But {@link #containsSymbol(Object)} returns true.
35 * </p>
36 *
37 * @author Patrick Harms
38 *
39 * @param <K>
40 *            Type of the symbols that are stored
41 * @param <V>
42 *            Type of the values associated with the symbols
43 *           
44 * @see SymbolStrategy
45 */
46public interface SymbolMap<K, V> extends Serializable {
47
48    /**
49     * <p>
50     * Returns the size of the map, i.e. the number of symbol entries
51     * </p>
52     *
53     * @return as described
54     */
55    public int size();
56
57    /**
58     * <p>
59     * Returns true if this map is empty, i.e. if {@link #size()} returns 0
60     * </p>
61     *
62     * @return as described
63     */
64    public boolean isEmpty();
65
66    /**
67     * <p>
68     * Returns true if the provided symbol was stored in this map.
69     * </p>
70     *
71     * @param symbol the symbol to check if it was stored in this map
72     *
73     * @return as described
74     *
75     * @throws IllegalArgumentException if the provided symbol is null
76     */
77    public boolean containsSymbol(K symbol);
78
79    /**
80     * <p>
81     * Returns the value associated to the provided symbol in this map. If there is no value
82     * associated to the given symbol or if the symbol is not stored in this map, the method
83     * returns null.
84     * </p>
85     *
86     * @param symbol the symbol to return the value for
87     *
88     * @return as described
89     *
90     * @throws IllegalArgumentException if the provided symbol is null
91     */
92    public V getValue(K symbol);
93
94    /**
95     * <p>
96     * Adds a symbol and an associated value to the map. If the value is null, the symbol is added,
97     * anyway and {@link #containsSymbol(Object)} will return true for that symbol. Adding the
98     * same symbol twice may produce two entries. This is contradictory to typical map
99     * implementations. To prevent this, the {@link #containsSymbol(Object)} and
100     * {@link #removeSymbol(Object)} methods should be used to ensure map behavior.
101     * </p>
102     *
103     * @param symbol the symbol to add to the map
104     * @param value  the value to associate to the symbol in this map
105     *
106     * @throws IllegalArgumentException if the provided symbol is null
107     */
108    public void addSymbol(K symbol, V value);
109
110    /**
111     * <p>
112     * Removes a symbol and its associated value from the map. If the symbol is stored several
113     * times, the first of its occurrences is removed.
114     * </p>
115     *
116     * @param symbol the symbol to be removed from the map
117     *
118     * @return as described
119     *
120     * @throws IllegalArgumentException if the provided symbol is null
121     */
122    public V removeSymbol(K symbol);
123
124    /**
125     * <p>
126     * Returns a collection of all symbols in this map.
127     * </p>
128     *
129     * @return as described
130     */
131    public Collection<K> getSymbols();
132   
133    /**
134     * <p>
135     * Returns a collection of all values associated to symbols in this map. May contain null
136     * values, if some of the symbols are mapped to null. The length of the returned collection
137     * is in any case the same as the size of the map.
138     * </p>
139     *
140     * @return as described
141     */
142    public Collection<V> getValues();
143   
144    /**
145     * <p>
146     * Removes all symbols and associated values from the map.
147     * </p>
148     */
149    public void clear();
150
151    /* (non-Javadoc)
152     * @see java.lang.Object#hashCode()
153     */
154    @Override
155    public int hashCode();
156
157    /* (non-Javadoc)
158     * @see java.lang.Object#equals(java.lang.Object)
159     */
160    @Override
161    public boolean equals(Object obj);
162
163}
Note: See TracBrowser for help on using the repository browser.