diff options
author | gluk256 <gluk256@users.noreply.github.com> | 2019-01-12 03:42:33 +0800 |
---|---|---|
committer | Viktor TrĂ³n <viktor.tron@gmail.com> | 2019-01-12 03:42:33 +0800 |
commit | 1636d9574be4e3df318f16bd1bf2741cf79b76a1 (patch) | |
tree | f3fb5986f98a1a149a65da93c9f9ddfff001f5fa /swarm/pot/pot.go | |
parent | 88168ff5c57b1a9c944d02e93e6e49368ccc968f (diff) | |
download | go-tangerine-1636d9574be4e3df318f16bd1bf2741cf79b76a1.tar go-tangerine-1636d9574be4e3df318f16bd1bf2741cf79b76a1.tar.gz go-tangerine-1636d9574be4e3df318f16bd1bf2741cf79b76a1.tar.bz2 go-tangerine-1636d9574be4e3df318f16bd1bf2741cf79b76a1.tar.lz go-tangerine-1636d9574be4e3df318f16bd1bf2741cf79b76a1.tar.xz go-tangerine-1636d9574be4e3df318f16bd1bf2741cf79b76a1.tar.zst go-tangerine-1636d9574be4e3df318f16bd1bf2741cf79b76a1.zip |
swarm/pot: pot.remove fixed (#18431)
* swarm/pot: refactored pot.remove(), updated comments
* swarm/pot: comments updated
Diffstat (limited to 'swarm/pot/pot.go')
-rw-r--r-- | swarm/pot/pot.go | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/swarm/pot/pot.go b/swarm/pot/pot.go index a71219779..0797b286c 100644 --- a/swarm/pot/pot.go +++ b/swarm/pot/pot.go @@ -144,13 +144,10 @@ func add(t *Pot, val Val, pof Pof) (*Pot, int, bool) { return r, po, found } -// Remove called on (v) deletes v from the Pot and returns -// the proximity order of v and a boolean value indicating -// if the value was found -// Remove called on (t, v) returns a new Pot that contains all the elements of t -// minus the value v, using the applicative remove -// the second return value is the proximity order of the inserted element -// the third is boolean indicating if the item was found +// Remove deletes element v from the Pot t and returns three parameters: +// 1. new Pot that contains all the elements of t minus the element v; +// 2. proximity order of the removed element v; +// 3. boolean indicating whether the item was found. func Remove(t *Pot, v Val, pof Pof) (*Pot, int, bool) { return remove(t, v, pof) } @@ -161,10 +158,7 @@ func remove(t *Pot, val Val, pof Pof) (r *Pot, po int, found bool) { if found { size-- if size == 0 { - r = &Pot{ - po: t.po, - } - return r, po, true + return &Pot{}, po, true } i := len(t.bins) - 1 last := t.bins[i] @@ -201,7 +195,7 @@ func remove(t *Pot, val Val, pof Pof) (r *Pot, po int, found bool) { } bins = append(bins, t.bins[j:]...) r = &Pot{ - pin: val, + pin: t.pin, size: size, po: t.po, bins: bins, |