MCPcopy Index your code
hub / github.com/EdwardRaff/JSAT / increment

Method increment

JSAT/src/jsat/utils/IntDoubleMap.java:130–155  ·  view source on GitHub ↗

@param key the key whose associated value is to be incremented. All non-present keys behave as having an implicit value of zero, in which case the delta value is directly inserted into the map. @param delta the amount by which to increment the key's stored value. @return the new value stored for the

(int key, double delta)

Source from the content-addressed store, hash-verified

128 * @return the new value stored for the given key
129 */
130 public double increment(int key, double delta)
131 {
132 if(Double.isNaN(delta))
133 throw new IllegalArgumentException("NaN is not an allowable value");
134
135 long pair_index = getIndex(key);
136 int deletedIndex = (int) (pair_index >>> 32);
137 int valOrFreeIndex = (int) (pair_index & INT_MASK);
138
139 if(status[valOrFreeIndex] == OCCUPIED)//easy case
140 return (table[valOrFreeIndex] += delta);
141 //else, not present
142 double toReturn;
143 int i = valOrFreeIndex;
144 if(deletedIndex >= 0)//use occupied spot instead
145 i = deletedIndex;
146
147 status[i] = OCCUPIED;
148 keys[i] = key;
149 toReturn = table[i] = delta;
150 used++;
151
152 enlargeIfNeeded();
153
154 return toReturn;
155 }
156
157 /**
158 * Returns the value to which the specified key is mapped, or

Callers 1

testIncrementMethod · 0.95

Calls 2

getIndexMethod · 0.95
enlargeIfNeededMethod · 0.95

Tested by 1

testIncrementMethod · 0.76