public void add(WorldModel model, int depth) { //get hash value int hashValue = model.getHash(); //find entry Entry entry = entries[hashValue % size]; if (entry == null) { entries[hashValue % size] = new Entry(); entries[hashValue % size].model = model; entries[hashValue % size].depth = depth; return; } //check if it's the right one if (entry.model.equals(model)) { //use the new depth if it is lower if (depth < entry.depth) { entry.depth = depth; } } else //replace this slot if the new depth is lower if (depth < entry.depth) { entry.model = model; entry.depth = depth; } }
public bool has(WorldModel model) { //get hash value int hashValue = model.getHash(); //find entry Entry entry = entries[hashValue % size]; if (entry == null) { return(false); } //check if it's the right one return(entry.model.equals(model)); }