diff --git a/dataext/stack.go b/dataext/stack.go index 6211334..d25d653 100644 --- a/dataext/stack.go +++ b/dataext/stack.go @@ -96,3 +96,12 @@ func (s *Stack[T]) OptPeek() *T { return langext.Ptr(s.data[l-1]) } + +func (s *Stack[T]) Length() int { + if s.lock != nil { + s.lock.Lock() + defer s.lock.Unlock() + } + + return len(s.data) +}