Example #1
0
  @SuppressWarnings({"unchecked", "rawtypes"})
  private Collection<BigInteger> getKeys(long have, long want) {

    // FILTER ALL KEYS
    Collection<BigInteger> keys =
        ((BTreeMap<Tuple4, BigInteger>) this.haveWantKeyMap)
            .subMap(Fun.t4(have, want, null, null), Fun.t4(have, want, Fun.HI(), Fun.HI()))
            .values();

    // IF THIS IS A FORK
    if (this.parent != null) {
      // GET ALL KEYS FOR FORK
      Collection<BigInteger> forkKeys = ((OrderMap) this.parent).getKeys(have, want);

      // COMBINE LISTS
      Set<BigInteger> combinedKeys = new TreeSet<BigInteger>(keys);
      combinedKeys.addAll(forkKeys);

      // DELETE DELETED
      for (BigInteger deleted : this.deleted) {
        combinedKeys.remove(deleted);
      }

      // CONVERT SET BACK TO COLLECTION
      keys = combinedKeys;
    }

    return keys;
  }
Example #2
0
  @SuppressWarnings({"unchecked", "rawtypes"})
  public SortableList<BigInteger, Order> getOrdersSortableList(long have, long want) {
    // FILTER ALL KEYS
    Collection<BigInteger> keys =
        ((BTreeMap<Tuple4, BigInteger>) this.haveWantKeyMap)
            .subMap(Fun.t4(have, want, null, null), Fun.t4(have, want, Fun.HI(), Fun.HI()))
            .values();

    // RETURN
    return new SortableList<BigInteger, Order>(this, keys);
  }