/*
 * Copyright 2017 tao.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.dongbat.jbump;

import java.util.HashSet;

/**
 *
 * @author tao
 */
public class Cell {
  public float x;
  public float y;
  public HashSet<Item> items = new HashSet<Item>();
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Cell cell = (Cell) o;

    return Float.compare(cell.x, x) == 0 && Float.compare(cell.y, y) == 0;
  }

  @Override
  public int hashCode() {
    return (int)(Float.floatToIntBits(x) * 0xC13FA9A902A6328FL
            + Float.floatToIntBits(y) * 0x91E10DA5C79E7B1DL >>> 32);
  }

}

@@ -621,22 +621,37 @@
 ort 
-java.util.Hash
+com.dongbat.jbump.util.Object
 Set;
@@ -740,477 +740,1259 @@
 ;%0A  
-public HashSet%3CItem%3E items = new HashSet%3CItem%3E();%0A  @Override%0A  public boolean equals(Object o) %7B%0A    if (this == o) return true;%0A    if (o == null %7C%7C getClass() != o.getClass()) return false;%0A%0A    Cell cell = (Cell) o;%0A%0A    return Float.compare(cell.x, x) == 0 && Float.compare(cell.y, y) == 0;%0A  %7D%0A%0A  @Override%0A  public int hashCode() %7B%0A    return (int)(Float.floatToIntBits(x) * 0xC13FA9A902A6328FL%0A            + Float.floatToI
+/**%0A   * This class is compared by identity, like %7B@link Item%7D, and it also caches its identityHashCode() result.%0A   */%0A  protected final int identityHash;%0A  /**%0A   * Stores the Item values in this Cell.%0A   * %3Cbr%3E%0A   * This uses a different implementation of Set than usual; %7B@link ObjectSet%7D reuses its iterators where HashSet does%0A   * not, and in general uses less memory. Avoiding GC pressure is important in games, especially those that target%0A   * mobile or web platforms, and JBump iterates over these items fairly often, so we don't want to create many%0A   * Iterators without needing to. ObjectSet doesn't support nested iteration over the same Set, so that is something to%0A   * be aware of. This was a HashSet, but ObjectSet implements about the same API.%0A   */%0A  public ObjectSet%3CItem%3E items = new ObjectSet%3C%3E(11);%0A%0A  /**%0A   * Constructs a Cell with a position of 0,0 and no items (it will be empty).%0A   * %3Cbr%3E%0A   * If you subclass Cell, you should call %7B@code super()%7D so the cached identity hash code is stored correctly.%0A   */%0A  public Cell() %7B%0A    identityHash = System.identityHashCode(this);%0A  %7D%0A%0A  @Override%0A  public boolean equals(Object o) %7B%0A    return (this == o);%0A  %7D%0A%0A  @Override%0A  public int hashCode() %7B%0A    return ide
 nt
-B
 it
-s(y) * 0x91E10DA5C79E7B1DL %3E%3E%3E 32)
+yHash
 ;%0A  

Use ObjectSet in Cell, fix Cell's equality/hashing.