MCPcopy Create free account
hub / github.com/ReadyTalk/avian / addAndReplace

Method addAndReplace

classpath/java/util/TreeSet.java:76–86  ·  view source on GitHub ↗
(T value)

Source from the content-addressed store, hash-verified

74 }
75
76 T addAndReplace(T value) {
77 PersistentSet.Path<Cell<T>> p = set.find(new Cell(value, null));
78 if (p.fresh()) {
79 set = p.add();
80 return null;
81 } else {
82 T old = p.value().value;
83 set = p.replaceWith(new Cell(value, null));
84 return old;
85 }
86 }
87
88 T find(T value) {
89 PersistentSet.Path<Cell<T>> p = set.find(new Cell(value, null));

Callers 2

putMethod · 0.80
addMethod · 0.80

Calls 5

freshMethod · 0.80
findMethod · 0.65
addMethod · 0.65
valueMethod · 0.45
replaceWithMethod · 0.45

Tested by

no test coverage detected