MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / add

Method add

libraries/SparseArray/SparseArray.cpp:82–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80
81
82bool SparseArray::add(uint16_t x, float value)
83{
84 int32_t pos = findPos(x);
85 // existing element
86 if (pos > -1)
87 {
88 _value[pos] += value;
89 if (_value[pos] == 0.0) removeElement(pos);
90 return true;
91 }
92
93 // does not exist => new element ?
94 return newElement(x, value);
95}
96
97
98float SparseArray::get(uint16_t x)

Callers 1

unittestFunction · 0.45

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.36