platform: Add log update interval

This commit is contained in:
世界
2024-06-18 17:49:06 +08:00
parent b1d75812c5
commit 7eec3fb57a
3 changed files with 71 additions and 47 deletions

View File

@@ -3,8 +3,9 @@ package libbox
import "github.com/sagernet/sing/common"
type StringIterator interface {
Next() string
Len() int32
HasNext() bool
Next() string
}
var _ StringIterator = (*iterator[string])(nil)
@@ -21,6 +22,14 @@ func newPtrIterator[T any](values []T) *iterator[*T] {
return &iterator[*T]{common.Map(values, func(value T) *T { return &value })}
}
func (i *iterator[T]) Len() int32 {
return int32(len(i.values))
}
func (i *iterator[T]) HasNext() bool {
return len(i.values) > 0
}
func (i *iterator[T]) Next() T {
if len(i.values) == 0 {
return common.DefaultValue[T]()
@@ -30,10 +39,6 @@ func (i *iterator[T]) Next() T {
return nextValue
}
func (i *iterator[T]) HasNext() bool {
return len(i.values) > 0
}
type abstractIterator[T any] interface {
Next() T
HasNext() bool