mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Implement PullBack()
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume.charmes@docker.com> (github: creack)
This commit is contained in:
parent
43bcbf06a6
commit
18df387bf8
1 changed files with 16 additions and 1 deletions
|
@ -28,9 +28,14 @@ func (s *iPSet) Push(elem string) {
|
||||||
s.Unlock()
|
s.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pop is an alias to PopFront()
|
||||||
|
func (s *iPSet) Pop() string {
|
||||||
|
return s.PopFront()
|
||||||
|
}
|
||||||
|
|
||||||
// Pop returns the first elemen from the list and removes it.
|
// Pop returns the first elemen from the list and removes it.
|
||||||
// If the list is empty, it returns an empty string
|
// If the list is empty, it returns an empty string
|
||||||
func (s *iPSet) Pop() string {
|
func (s *iPSet) PopFront() string {
|
||||||
s.RLock()
|
s.RLock()
|
||||||
|
|
||||||
for i, e := range s.set {
|
for i, e := range s.set {
|
||||||
|
@ -45,6 +50,16 @@ func (s *iPSet) Pop() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PullBack retrieve the last element of the list.
|
||||||
|
// The element is not removed.
|
||||||
|
// If the list is empty, an empty element is returned.
|
||||||
|
func (s *iPSet) PullBack() string {
|
||||||
|
if len(s.set) == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return s.set[len(s.set)-1]
|
||||||
|
}
|
||||||
|
|
||||||
// Exists checks if the given element present in the list.
|
// Exists checks if the given element present in the list.
|
||||||
func (s *iPSet) Exists(elem string) bool {
|
func (s *iPSet) Exists(elem string) bool {
|
||||||
for _, e := range s.set {
|
for _, e := range s.set {
|
||||||
|
|
Loading…
Reference in a new issue