package chart_parser;

import java.util.HashMap;

import cat_combination.SuperCategory;

public class CategoryEquivalence {
	/*
	 * keys are triples of (position, span, SuperCategory); value becomes the *last*
	 * SuperCategory in the linked list of equivalents
	 */
	// should refactor into Hashmap<EquivKey, LinkedList<SuperCategory>>!
	private HashMap<EquivKey, SuperCategory> equiv;

	public CategoryEquivalence(int initCapacity) {
		equiv = new HashMap<EquivKey, SuperCategory>(initCapacity);
	}

	/*
	 * returns true if equivalent category not already there, false otherwise
	 */
	public boolean add(int position, int span, SuperCategory superCat) {
		EquivKey equivKey = new EquivKey(position, span, superCat);
		SuperCategory value = equiv.get(equivKey);
		equiv.put(equivKey, superCat);
		// overrides the previous value (if there was one)

		if (value != null) {
			value.next = superCat;
			return false;
		} else {
			return true;
		}
	}

	public void clear() {
		equiv.clear();
	}
}

@@ -731,39 +731,24 @@
 ory 
-v
+previousV
 alue = 
-equiv.get(equivKey);%0A%09%09
 equi
@@ -783,16 +783,20 @@
 %09// 
-override
+put() return
 s th
@@ -811,18 +811,26 @@
 us value
+, or null
  
-(
 if there
@@ -838,21 +838,49 @@
 was 
-one)%0A%0A%09%09if (v
+no mapping for the key%0A%09%09%0A%09%09if (previousV
 alue
@@ -894,17 +894,25 @@
 l) %7B%0A%09%09%09
-v
+previousV
 alue.nex

Modify add() to save one extra get() call to HashMap.