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

Last change on this file since 1251 was 1251, checked in by pharms, 11 years ago
  • improved performance of the trie for large alphabets by using the symbol map. This is an improved list of symbols that allows a more efficient lookup for symbols using buckets of symbol as an initial search order
File size: 1.8 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
17/**
18 * <p>
19 * Default implementation for the {@link SymbolComparator} using the equals method of the provided
20 * symbols for comparison. The {@link #equals(Object, Object)} method will also return true if
21 * both symbols are <code>null</code>
22 * </p>
23 *
24 * @author Patrick Harms
25 */
26public class DefaultSymbolComparator<T> implements SymbolComparator<T> {
27
28    /**  */
29    private static final long serialVersionUID = 1L;
30
31    /* (non-Javadoc)
32     * @see de.ugoe.cs.autoquest.tasktrees.temporalrelation.SymbolComparator#equals(Object, Object)
33     */
34    @Override
35    public boolean equals(T symbol1, T symbol2) {
36        if (symbol1 == null) {
37            return (symbol2 == null);
38        }
39        else {
40            return symbol1.equals(symbol2);
41        }
42    }
43
44    /* (non-Javadoc)
45     * @see de.ugoe.cs.autoquest.usageprofiles.SymbolComparator#getBucketSearchOrder(Object)
46     */
47    @Override
48    public int[] getBucketSearchOrder(T symbol) {
49        if (symbol != null) {
50            return new int[] { symbol.hashCode() };
51        }
52        else {
53            return null;
54        }
55    }
56
57}
Note: See TracBrowser for help on using the repository browser.