You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// TODO: Why not just use list.elemens = append(list.elements, ...values)?
shrinkFactor=float32(0.25) // shrink when size is 25% of capacity (0 means never shrink)
)
// New instantiates a new list and adds the passed values, if any, to the list.funcNew[Tany](values...T) *List[T] {
list:=&List[T]{}
iflen(values) >0 {
list.PushBack(values...)
}
returnlist
}
// NewFromSLice instantiates a new list containing the provided slice.funcNewFromSlice[Tany](slice []T) *List[T] {
list:=&List[T]{elements: slice, size: len(slice)}
returnlist
}
// Add appends a value at the end of the list.func (list*List[T]) PushBack(values...T) {
// TODO: Why not just use list.elemens = append(list.elements, ...values)?// https://github.com/golang/go/blob/master/src/runtime/slice.golist.growBy(len(values))
for_, value:=rangevalues {
list.elements[list.size] =value
5f13fa0c5b83e523cacbcc2c2244deed2b53f9fa
The text was updated successfully, but these errors were encountered:
Why not just use list.elemens = append(list.elements, ...values)?
https://github.com/golang/go/blob/master/src/runtime/slice.go
datastructures.go/lists/arraylist/arraylist.go
Line 55 in 15011d9
5f13fa0c5b83e523cacbcc2c2244deed2b53f9fa
The text was updated successfully, but these errors were encountered: