@@ -32,6 +32,8 @@ Relates to https://github.com/RobTillaart/distanceTable
3232The implementation is based on 3 arrays holding ``` x, y, value ``` where value is float.
3333In the future other datatypes should be possible.
3434
35+ #### Performance
36+
3537The elements are not kept sorted or indexed so optimizations are possible
3638but not investigated yet.
3739
@@ -43,10 +45,15 @@ Parameter is the maximum number of elements in the sparse matrix.
4345- ** uint8_t size()** maximum number of elements.
4446- ** uint8_t count()** current number of elements in the matrix.
4547- ** float sum()** sum of all elements ( > 0 ) in the matrix.
48+ - ** void clear()** resets the matrix to all zero's again.
4649- ** bool set(uint8_t x, uint8_t y, float value)** gives an element in the matrix a value.
4750If the value is set to zero, it is removed from the internal store.
4851Returns false if the internal store is full, true otherwise.
4952- ** float get(uint8_t x, uint8_t y)** returns the value in the matrix.
53+ - ** bool add(uint8_t x, uint8_t y, float value)** adds a value to an element in the matrix.
54+ If needed a new internal element is created.
55+ If the sum is zero, the element is removed from the internal store.
56+ Returns false if the internal store is full, true otherwise.
5057
5158
5259## Future
@@ -61,23 +68,19 @@ Returns false if the internal store is full, true otherwise.
6168 - 2D histogram e.g. temperature vs humidity
6269 - N queens game.
6370- investigate optimizations.
64- - should ** set()** return the number of free places?
71+ - should ** set()** and ** add() ** return the number of free places?
6572 - no hard code and more informative than just a bool.
73+ - can ** set()** and ** add()** be merged?
6674- add link in distanceTable repo
6775- uint16_t size for larger platforms.
6876 - max matrix still 255 x 255 but more elements <> 0.
6977
7078
7179#### new functions
7280
73- - ** float add(uint8_t x, uint8_t y, float value)** adds value to the x,y position.
74- - add or remove an internal element if needed,
75- - functional ** set(x,y, get(x,y) + value)**
76- - ** void clear()** sets all elements to zero again.
77- - \_ count = 0; should be sufficient.
78- - walking through the elements?
81+ - walk through the elements?
7982 - first -> next; last -> prev.
80-
83+
8184
8285#### won't
8386
0 commit comments