Browse Source

unified method signatures

master v0.2.0
Pixdigit 4 years ago
parent
commit
11da41248f
  1. 7
      set.go
  2. 4
      set_test.go

7
set.go

@ -59,9 +59,10 @@ func (s *Set) Insert(uElem uniqueElem, value Num) error {
return nil
}
func (s *Set) SetValue(ID uniqueID.ID, value Num) error {
func (s *Set) SetValue(elem uniqueElem, value Num) error {
elemID := elem.ID()
for i, elem := range s.elems {
if elem.ID() == ID {
if elem.ID() == elemID {
elem.value = value
//remove elem from array
s.elems = append(s.elems[:i], s.elems[i+1:]...)
@ -70,7 +71,7 @@ func (s *Set) SetValue(ID uniqueID.ID, value Num) error {
return nil
}
}
return ErrNoElem{ID}
return ErrNoElem{elemID}
}
func (s *Set) Nearest(value Num) (interface{}, error) {

4
set_test.go

@ -120,8 +120,8 @@ func TestSetValue(t *testing.T) {
tools.WrapErr(err, "could not insert test element", t)
}
set.SetValue(a.ID(), 3.5)
set.SetValue(e.ID(), -2)
set.SetValue(a, 3.5)
set.SetValue(e, -2)
tools.Test(set.Elems()[0] == e, "did not correctly change position when set new value", t)
tools.Test(set.Elems()[1] == b, "did not correctly change position when set new value", t)

Loading…
Cancel
Save