Example #1
0
/** Created by wayne on 15/10/27. */
public final class IRUnop extends IRExp {
  public final Uop op;
  public final IRExp e;
  final int recordHash;
  static final Hash<P2<Uop, IRExp>> hash = Hash.p2Hash(Hash.anyHash(), Hash.anyHash());

  public IRUnop(Uop op, IRExp e) {
    this.op = op;
    this.e = e;
    this.recordHash = hash.hash(P.p(op, e));
  }

  @Override
  public boolean equals(Object obj) {
    return (obj instanceof IRUnop && op.equals(((IRUnop) obj).op) && e.equals(((IRUnop) obj).e));
  }

  @Override
  public int hashCode() {
    return recordHash;
  }

  @Override
  public FHashSet<IRPVar> free() {
    return e.free();
  }

  @Override
  public String toString() {
    return op + "(" + e + ")";
  }

  @Override
  public <T> T accept(IRExpVisitor<T> ask) {
    return ask.forUnop(this);
  }

  @Override
  public IRExp accept(SimpleTransformVisitor ask) {
    return ask.forUnop(this);
  }

  @Override
  public <T> P2<IRExp, T> accept(TransformVisitor<T> ask) {
    return ask.forUnop(this);
  }
}
Example #2
0
 public HashMap(java.util.Map<K, V> map) {
   this(map, Equal.anyEqual(), Hash.anyHash());
 }
Example #3
0
 /** Converts the Iterable to a HashMap */
 public static <K, V> HashMap<K, V> iterableHashMap(final Iterable<P2<K, V>> entries) {
   return iterableHashMap(Equal.anyEqual(), Hash.anyHash(), entries);
 }
Example #4
0
 public static <K, V> HashMap<K, V> fromMap(java.util.Map<K, V> map) {
   return fromMap(Equal.anyEqual(), Hash.anyHash(), map);
 }
Example #5
0
 public <A> HashMap<A, V> mapKeys(F<K, A> function) {
   return mapKeys(function, Equal.anyEqual(), Hash.anyHash());
 }
Example #6
0
 public <A, B> HashMap<A, B> map(F<K, A> keyFunction, F<V, B> valueFunction) {
   return map(keyFunction, valueFunction, Equal.anyEqual(), Hash.anyHash());
 }
Example #7
0
 /**
  * Compute the hash of the given key value using the underlying hashing strategy.
  *
  * @param k The key value to computer the hash of.
  * @return The hash of the given key value.
  */
 public int hash(final K k) {
   return h.hash(k);
 }
Example #8
0
 /**
  * Construct a hash map that uses {@link Object#equals} and {@link Object#hashCode}.
  *
  * @return A new hash map that uses {@link Object#equals} and {@link Object#hashCode}.
  */
 public static <K, V> HashMap<K, V> hashMap() {
   return hashMap(Equal.anyEqual(), Hash.anyHash());
 }
Example #9
0
 @Override
 public int hashCode() {
   return Hash.treeHash(Hash.<A>anyHash()).hash(this);
 }
Example #10
0
 @Override
 public int hashCode() {
   return Hash.nonEmptyListHash(Hash.<A>anyHash()).hash(this);
 }