MCPcopy Create free account
hub / github.com/LFYSec/MScan / SetFact

Class SetFact

src/main/java/pascal/taie/analysis/dataflow/fact/SetFact.java:43–207  ·  view source on GitHub ↗

Represents set-like data-flow facts. @param type of elements

Source from the content-addressed store, hash-verified

41 * @param <E> type of elements
42 */
43public class SetFact<E> implements Copyable<SetFact<E>>, Iterable<E> {
44
45 protected final Set<E> set;
46
47 public SetFact(Collection<E> c) {
48 if (c instanceof GenericBitSet<E> s) {
49 set = s.copy();
50 } else {
51 set = Sets.newHybridSet(c);
52 }
53 }
54
55 public SetFact() {
56 this(Collections.emptySet());
57 }
58
59 /**
60 * @return true if this set contains the specified element, otherwise false.
61 */
62 public boolean contains(E e) {
63 return set.contains(e);
64 }
65
66 /**
67 * Adds an element to this fact.
68 *
69 * @return true if this fact changed as a result of the call, otherwise false.
70 */
71 public boolean add(E e) {
72 return set.add(e);
73 }
74
75 /**
76 * Removes an element from this fact.
77 *
78 * @return true if an element was removed as a result of the call, otherwise false.
79 */
80 public boolean remove(E e) {
81 return set.remove(e);
82 }
83
84 /**
85 * Removes all the elements of this fact that satisfy the given predicate.
86 *
87 * @return true if any elements were removed as a result of the call,
88 * otherwise false.
89 */
90 public boolean removeIf(Predicate<E> filter) {
91 return set.removeIf(filter);
92 }
93
94 /**
95 * Removes all elements of other fact.
96 *
97 * @return true if this fact changed as a result of the call, otherwise false.
98 */
99 public boolean removeAll(SetFact<E> other) {
100 return set.removeAll(other.set);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected