MCPcopy Create free account
hub / github.com/apache/pig / removeWithPosition

Method removeWithPosition

src/org/apache/pig/newplan/PlanEdge.java:77–102  ·  view source on GitHub ↗

Remove one value from an existing key and return which position in the arraylist the value was at.. If that is the last value for the key, then remove the key too. @param key Key to remove the value from. @param value Value to remove. @return A pair containing the value being removed and an integer

(Operator key,
                                                      Operator value)

Source from the content-addressed store, hash-verified

75 * not exist. Positions are zero based.
76 */
77 public Pair<Operator, Integer> removeWithPosition(Operator key,
78 Operator value) {
79 ArrayList<Operator> list = mMap.get(key);
80 if (list == null) return null;
81
82 int index = -1;
83 Iterator<Operator> i = list.iterator();
84 Operator keeper = null;
85 for (int j = 0; i.hasNext(); j++) {
86 keeper = i.next();
87 //if (keeper.equals(value)) {
88 if (keeper == value) {
89 i.remove();
90 index = j;
91 break;
92 }
93 }
94
95 if (index == -1) return null;
96
97 if (list.size() == 0) {
98 mMap.remove(key);
99 }
100
101 return new Pair<Operator, Integer>(keeper, index);
102 }
103
104 public PlanEdge shallowClone() {
105 // shallow clone: elements not cloned

Callers 1

disconnectMethod · 0.80

Calls 6

getMethod · 0.65
iteratorMethod · 0.65
removeMethod · 0.65
sizeMethod · 0.65
hasNextMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected