MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / HashSet

Class HashSet

src/main/java/wyil/util/BinaryRelation.java:59–80  ·  view source on GitHub ↗

A simple and rather inefficient implementation of BinaryRelation which employs a HashSet underneath. @author David J. Pearce @param

Source from the content-addressed store, hash-verified

57 * @param <T>
58 */
59 public static class HashSet<T> implements BinaryRelation<T> {
60 private java.util.HashSet<Pair<T, T>> relations;
61
62 public HashSet() {
63 this.relations = new java.util.HashSet<>();
64 }
65
66 @Override
67 public boolean get(T lhs, T rhs) {
68 return relations.contains(new Pair<>(lhs, rhs));
69 }
70
71 @Override
72 public void set(T lhs, T rhs, boolean value) {
73 Pair<T, T> p = new Pair<>(lhs, rhs);
74 if (value) {
75 relations.add(p);
76 } else {
77 relations.remove(p);
78 }
79 }
80 }
81}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected