Documentation
¶
Index ¶
- func Add(a, b int) int
- type ArrayList
- func (a *ArrayList[T]) Append(newVal T)
- func (a *ArrayList[T]) Clear()
- func (a *ArrayList[T]) Contains(val T) bool
- func (a *ArrayList[T]) Delete(index int) error
- func (a *ArrayList[T]) Get(index int) (T, error)
- func (a *ArrayList[T]) Insert(index int, newVal T) error
- func (a *ArrayList[T]) IsEmpty() bool
- func (a *ArrayList[T]) Set(index int, newVal T) error
- func (a *ArrayList[T]) Size() int
- type LinkedList
- func (l *LinkedList[T]) Append(newVal T)
- func (l *LinkedList[T]) Clear()
- func (l *LinkedList[T]) Contains(val T) bool
- func (l *LinkedList[T]) Delete(index int) error
- func (l *LinkedList[T]) Get(index int) (T, error)
- func (l *LinkedList[T]) Insert(index int, newVal T) error
- func (l *LinkedList[T]) IsEmpty() bool
- func (l *LinkedList[T]) Set(index int, newVal T) error
- func (l *LinkedList[T]) Size() int
- type List
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArrayList ¶
type ArrayList[T any] struct { // contains filtered or unexported fields }
ArrayList 结构体用于存储数组列表的元素和大小
func (*ArrayList[T]) Append ¶
func (a *ArrayList[T]) Append(newVal T)
Append a new value to the ArrayList
func (*ArrayList[T]) Insert ¶
Insert function inserts a new value into an array list at a given index
type LinkedList ¶
type LinkedList[T any] struct { // contains filtered or unexported fields }
LinkedList 采用带头节点的双循环链表
func (*LinkedList[T]) Insert ¶
func (l *LinkedList[T]) Insert(index int, newVal T) error
Insert 在指定位置插入元素
type List ¶
type List[T any] interface { // Size return the length of list Size() int //IsEmpty return whether the list is empty IsEmpty() bool //Clear the method which is clear the list Clear() //Get return the element based on index //if it doesn't exist,return nil and error //if it does exist,return the element and nil Get(index int) (T, error) //Contains return the val does exist in this list or not Contains(val T) bool //Set the element in this list based on index //if failed,it will be return an error; //if successful, return nil Set(index int, newVal T) error //Insert an element to this list based on index //if failed,return an error //if successful,return nil Insert(index int, newVal T) error //Append a newVal to end of this list Append(newVal T) //Delete an element in this list based on index Delete(index int) error }
Click to show internal directories.
Click to hide internal directories.