|
@@ -154,11 +154,27 @@ func (s *List) pushFront(v interface{}) *Element {
|
|
|
return elem
|
|
|
}
|
|
|
|
|
|
+func (s *List) RemoveVal(val any) (ok bool) {
|
|
|
+ s.m.Lock()
|
|
|
+ elem := s.search(val)
|
|
|
+ if elem != nil {
|
|
|
+ s.removeElem(elem)
|
|
|
+ ok = true
|
|
|
+ }
|
|
|
+ s.m.Unlock()
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
func (s *List) Remove(elem *Element) {
|
|
|
if elem == nil {
|
|
|
return
|
|
|
}
|
|
|
s.m.Lock()
|
|
|
+ s.removeElem(elem)
|
|
|
+ s.m.Unlock()
|
|
|
+}
|
|
|
+
|
|
|
+func (s *List) removeElem(elem *Element) {
|
|
|
if elem == s.first {
|
|
|
s.first = elem.next
|
|
|
}
|
|
@@ -167,7 +183,6 @@ func (s *List) Remove(elem *Element) {
|
|
|
}
|
|
|
elem.destroy()
|
|
|
s.size--
|
|
|
- s.m.Unlock()
|
|
|
}
|
|
|
|
|
|
func (s *List) Size() (size int) {
|