|
|
@@ -73,6 +73,11 @@ func (v SliceView[T, V]) IsNil() bool { return v.ж == nil }
|
|
|
// Len returns the length of the slice.
|
|
|
func (v SliceView[T, V]) Len() int { return len(v.ж) }
|
|
|
|
|
|
+// LenIter returns a slice the same length as the v.Len().
|
|
|
+// The caller can then range over it to get the valid indexes.
|
|
|
+// It does not allocate.
|
|
|
+func (v SliceView[T, V]) LenIter() []struct{} { return make([]struct{}, len(v.ж)) }
|
|
|
+
|
|
|
// At returns a View of the element at index `i` of the slice.
|
|
|
func (v SliceView[T, V]) At(i int) V { return v.ж[i].View() }
|
|
|
|
|
|
@@ -129,6 +134,11 @@ func (v Slice[T]) IsNil() bool { return v.ж == nil }
|
|
|
// Len returns the length of the slice.
|
|
|
func (v Slice[T]) Len() int { return len(v.ж) }
|
|
|
|
|
|
+// LenIter returns a slice the same length as the v.Len().
|
|
|
+// The caller can then range over it to get the valid indexes.
|
|
|
+// It does not allocate.
|
|
|
+func (v Slice[T]) LenIter() []struct{} { return make([]struct{}, len(v.ж)) }
|
|
|
+
|
|
|
// At returns the element at index `i` of the slice.
|
|
|
func (v Slice[T]) At(i int) T { return v.ж[i] }
|
|
|
|
|
|
@@ -233,6 +243,11 @@ func (v IPPrefixSlice) IsNil() bool { return v.ж.IsNil() }
|
|
|
// Len returns the length of the slice.
|
|
|
func (v IPPrefixSlice) Len() int { return v.ж.Len() }
|
|
|
|
|
|
+// LenIter returns a slice the same length as the v.Len().
|
|
|
+// The caller can then range over it to get the valid indexes.
|
|
|
+// It does not allocate.
|
|
|
+func (v IPPrefixSlice) LenIter() []struct{} { return make([]struct{}, v.ж.Len()) }
|
|
|
+
|
|
|
// At returns the IPPrefix at index `i` of the slice.
|
|
|
func (v IPPrefixSlice) At(i int) netip.Prefix { return v.ж.At(i) }
|
|
|
|