diff options
Diffstat (limited to '')
-rw-r--r-- | c_lhosts.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/c_lhosts.go b/c_lhosts.go index 8e9a416..d98305c 100644 --- a/c_lhosts.go +++ b/c_lhosts.go @@ -110,6 +110,7 @@ func (lhost *HostList) del(id uint64) { // return the list node with the according id func (lhost *HostList) sel(id uint64) *HostNode { curr := lhost.head + for curr.next != nil && curr.ID != id { curr = curr.next } @@ -118,3 +119,14 @@ func (lhost *HostList) sel(id uint64) *HostNode { } return curr } + +func (lhost *HostList) count() uint64 { + curr := lhost.head + var count uint64 = 0 + + for curr != nil { + curr = curr.next + count++ + } + return count +} |