listx

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package listx Created by xuzhuoxi on 2019-04-03. @author xuzhuoxi

Package listx Created by xuzhuoxi on 2019-04-03. @author xuzhuoxi

Package listx Created by xuzhuoxi on 2019-04-03. @author xuzhuoxi

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayList

type ArrayList struct {
	// contains filtered or unexported fields
}

func NewArrayList

func NewArrayList(maxSize, initCap int) *ArrayList

NewArrayList 实例化一个用数组实现的List ArrayList maxSize: 列表允许的最大长度 initCap: 列表数组的初始化cap maxSize >= initCap

func (*ArrayList) Add

func (l *ArrayList) Add(ele ...interface{}) (suc bool)

func (*ArrayList) AddAll

func (l *ArrayList) AddAll(index int, list IList) (suc bool)

func (*ArrayList) AddAt

func (l *ArrayList) AddAt(index int, ele ...interface{}) (suc bool)

func (*ArrayList) Clear

func (l *ArrayList) Clear()

func (*ArrayList) Contains

func (l *ArrayList) Contains(ele interface{}) (contains bool)

func (*ArrayList) First

func (l *ArrayList) First() (ele interface{}, ok bool)

func (*ArrayList) FirstMulti

func (l *ArrayList) FirstMulti(amount int) (ele []interface{}, ok bool)

func (*ArrayList) ForEach

func (l *ArrayList) ForEach(each func(index int, ele interface{}) (stop bool))

func (*ArrayList) ForEachLast

func (l *ArrayList) ForEachLast(each func(index int, ele interface{}) (stop bool))

func (*ArrayList) Get

func (l *ArrayList) Get(index int) (ele interface{}, ok bool)

func (*ArrayList) GetAll

func (l *ArrayList) GetAll() []interface{}

func (*ArrayList) GetMulti

func (l *ArrayList) GetMulti(index int, amount int) (ele []interface{}, ok bool)

func (*ArrayList) GetMultiLast

func (l *ArrayList) GetMultiLast(lastIndex int, amount int) (ele []interface{}, ok bool)

func (*ArrayList) IndexOf

func (l *ArrayList) IndexOf(ele interface{}) (index int, ok bool)

func (*ArrayList) Last

func (l *ArrayList) Last() (ele interface{}, ok bool)

func (*ArrayList) LastIndexOf

func (l *ArrayList) LastIndexOf(ele interface{}) (index int, ok bool)

func (*ArrayList) LastMulti

func (l *ArrayList) LastMulti(amount int) (ele []interface{}, ok bool)

func (*ArrayList) Len

func (l *ArrayList) Len() int

func (*ArrayList) RemoveAt

func (l *ArrayList) RemoveAt(index int) (ele interface{}, suc bool)

func (*ArrayList) RemoveFirst

func (l *ArrayList) RemoveFirst() (ele interface{}, suc bool)

func (*ArrayList) RemoveFirstMulti

func (l *ArrayList) RemoveFirstMulti(amount int) (ele []interface{}, suc bool)

func (*ArrayList) RemoveLast

func (l *ArrayList) RemoveLast() (ele interface{}, suc bool)

func (*ArrayList) RemoveLastMulti

func (l *ArrayList) RemoveLastMulti(amount int) (ele []interface{}, suc bool)

func (*ArrayList) RemoveMultiAt

func (l *ArrayList) RemoveMultiAt(index int, amount int) (ele []interface{}, suc bool)

func (*ArrayList) Swap

func (l *ArrayList) Swap(i, j int)

type IList

type IList interface {
	// Len
	//the number of elements in the collection.
	Len() int
	// Swap
	// swaps the elements with indexes i and j.
	Swap(i, j int)
	// Clear
	// Removes all of the elements from this list (optional operation).
	Clear()

	// Add
	// Appends the elements to the end of this list (optional operation).
	Add(ele ...interface{}) (suc bool)
	// AddAt
	// Inserts the specified elements at the specified position in this list (optional operation).
	AddAt(index int, ele ...interface{}) (suc bool)
	// AddAll
	// Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation)
	AddAll(index int, list IList) (suc bool)

	// RemoveAt
	// Removes the element at the specified position in this list (optional operation).
	RemoveAt(index int) (ele interface{}, suc bool)
	// RemoveMultiAt
	// Removes some elements at the specified position in this list (optional operation).
	RemoveMultiAt(index int, amount int) (ele []interface{}, suc bool)
	// RemoveLast
	// Removes the last element at from this list (optional operation).
	RemoveLast() (ele interface{}, suc bool)
	// RemoveLastMulti
	// Removes some elements from this list started at the last position.
	RemoveLastMulti(amount int) (ele []interface{}, suc bool)
	// RemoveFirst
	// Removes the first element at from this list (optional operation).
	RemoveFirst() (ele interface{}, suc bool)
	// RemoveFirstMulti
	// Removes some elements from this list started at the first position.
	RemoveFirstMulti(amount int) (ele []interface{}, suc bool)

	// Get
	// Returns the element at the specified position in this list.
	Get(index int) (ele interface{}, ok bool)
	// GetMulti
	// Returns some elements in this list started at the specified position.
	GetMulti(index int, amount int) (ele []interface{}, ok bool)
	// GetMultiLast
	// Returns some elements in this list started at the specified position.
	GetMultiLast(lastIndex int, amount int) (ele []interface{}, ok bool)
	// GetAll
	// Returns all elements in this list.
	GetAll() []interface{}
	// First
	// Returns the first element of this list.
	First() (ele interface{}, ok bool)
	// FirstMulti
	// Returns some elements in this list started at the first position.
	FirstMulti(amount int) (ele []interface{}, ok bool)
	// Last
	// Returns the last element of this list.
	Last() (ele interface{}, ok bool)
	// LastMulti
	// Returns some elements in this list started at the last position.
	LastMulti(amount int) (ele []interface{}, ok bool)

	// IndexOf
	// Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
	IndexOf(ele interface{}) (index int, ok bool)
	// LastIndexOf
	// Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
	LastIndexOf(ele interface{}) (index int, ok bool)
	// Contains
	// Returns true if this list contains the specified element.
	Contains(ele interface{}) (contains bool)
	// ForEach
	// Performs the given action for each element of the list
	ForEach(each func(index int, ele interface{}) (stop bool))
	// ForEachLast
	// Performs the given action for each element of the list
	ForEachLast(each func(index int, ele interface{}) (stop bool))
}

type LinkedList

type LinkedList struct {
	// contains filtered or unexported fields
}

func NewLinkedList

func NewLinkedList() *LinkedList

NewLinkedList 实例化一个基于链表实现的List LinkedList

func (*LinkedList) Add

func (l *LinkedList) Add(ele ...interface{}) (suc bool)

func (*LinkedList) AddAll

func (l *LinkedList) AddAll(index int, list IList) (suc bool)

func (*LinkedList) AddAt

func (l *LinkedList) AddAt(index int, ele ...interface{}) (suc bool)

func (*LinkedList) Clear

func (l *LinkedList) Clear()

func (*LinkedList) Contains

func (l *LinkedList) Contains(ele interface{}) (contains bool)

func (*LinkedList) First

func (l *LinkedList) First() (ele interface{}, ok bool)

func (*LinkedList) FirstMulti

func (l *LinkedList) FirstMulti(amount int) (ele []interface{}, ok bool)

func (*LinkedList) ForEach

func (l *LinkedList) ForEach(each func(index int, ele interface{}) (stop bool))

func (*LinkedList) ForEachLast

func (l *LinkedList) ForEachLast(each func(index int, ele interface{}) (stop bool))

func (*LinkedList) Get

func (l *LinkedList) Get(index int) (ele interface{}, ok bool)

func (*LinkedList) GetAll

func (l *LinkedList) GetAll() []interface{}

func (*LinkedList) GetMulti

func (l *LinkedList) GetMulti(index int, amount int) (ele []interface{}, ok bool)

func (*LinkedList) GetMultiLast

func (l *LinkedList) GetMultiLast(lastIndex int, amount int) (ele []interface{}, ok bool)

func (*LinkedList) IndexOf

func (l *LinkedList) IndexOf(ele interface{}) (index int, ok bool)

func (*LinkedList) Last

func (l *LinkedList) Last() (ele interface{}, ok bool)

func (*LinkedList) LastIndexOf

func (l *LinkedList) LastIndexOf(ele interface{}) (index int, ok bool)

func (*LinkedList) LastMulti

func (l *LinkedList) LastMulti(amount int) (ele []interface{}, ok bool)

func (*LinkedList) Len

func (l *LinkedList) Len() int

func (*LinkedList) RemoveAt

func (l *LinkedList) RemoveAt(index int) (ele interface{}, suc bool)

func (*LinkedList) RemoveFirst

func (l *LinkedList) RemoveFirst() (ele interface{}, suc bool)

func (*LinkedList) RemoveFirstMulti

func (l *LinkedList) RemoveFirstMulti(amount int) (ele []interface{}, suc bool)

func (*LinkedList) RemoveLast

func (l *LinkedList) RemoveLast() (ele interface{}, suc bool)

func (*LinkedList) RemoveLastMulti

func (l *LinkedList) RemoveLastMulti(amount int) (ele []interface{}, suc bool)

func (*LinkedList) RemoveMultiAt

func (l *LinkedList) RemoveMultiAt(index int, amount int) (ele []interface{}, suc bool)

func (*LinkedList) Swap

func (l *LinkedList) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL