MCPcopy Create free account
hub / github.com/5zig/The-5zig-Mod / update

Method update

Mod Utils/src/eu/the5zig/mod/manager/SearchEntry.java:133–169  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

131 }
132
133 private void update() {
134 String text = textfield.getText();
135 List<T> addList = Lists.newArrayList();
136 List<T> removeList = Lists.newArrayList();
137 synchronized (entries) {
138 for (T o : entries) {
139 if (!entriesRemoved.contains(o) && !filter(text, o)) {
140 removeList.add(o);
141 }
142 }
143 }
144 for (T o : entriesRemoved) {
145 synchronized (entries) {
146 if (!entries.contains(o) && filter(text, o)) {
147 addList.add(o);
148 }
149 }
150 }
151 entriesRemoved.addAll(removeList);
152 entriesRemoved.removeAll(addList);
153 synchronized (entries) {
154 entries.removeAll(removeList);
155 for (T o : addList) {
156 int addIndex = getAddIndex();
157 if (addIndex < 0) {
158 entries.add(o);
159 } else {
160 while (addIndex > entries.size() - 1)
161 addIndex--;
162 entries.add(addIndex < 0 ? 0 : addIndex, o);
163 }
164 }
165 }
166 if (!addList.isEmpty()) {
167 sort();
168 }
169 }
170
171 public void setVisible(boolean visible) {
172 this.visible = visible;

Callers 1

keyTypedMethod · 0.95

Calls 8

filterMethod · 0.95
getAddIndexMethod · 0.95
sortMethod · 0.95
sizeMethod · 0.80
isEmptyMethod · 0.80
getTextMethod · 0.65
containsMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected