Documentation ¶
Index ¶
- func Abs(a int) int
- func AbsDiff(a, b int) int
- func ChanToSlice(ch chan int) []int
- func Contain(s []int, target int) bool
- func ContainString(s []string, target string) bool
- func Equal(t *testing.T, expected, result interface{})
- func IsLessThan1Apart(a, b int) bool
- func IsMoreThan1Apart(a, b int) bool
- func LinkedListToSlice(node *ListNode) []int
- func Log(m map[string]interface{})
- func Max(nums ...int) int
- func Mimax(nums ...int) (int, int)
- func Min(nums ...int) int
- func Random(min, max int) int
- func SumInt(nums []int) int
- func Swap(v interface{}, i, j int)
- func SwapInt(a []int, i, j int)
- func SwapString(a []string, i, j int)
- type List
- func (l *List) Back() interface{}
- func (l *List) Front() interface{}
- func (l *List) InsertAfter(v, mark interface{})
- func (l *List) InsertBefore(v, mark interface{})
- func (l *List) Len() interface{}
- func (l *List) MoveAfter(v, mark interface{})
- func (l *List) MoveBack(v interface{})
- func (l *List) MoveBefore(v, mark interface{})
- func (l *List) MoveFront(v interface{})
- func (l *List) PushBack(v interface{}) interface{}
- func (l *List) PushFront(v interface{}) interface{}
- func (l *List) RemoveBack() interface{}
- func (l *List) RemoveFront() interface{}
- func (l *List) Slice() []interface{}
- type ListNode
- type MaxHeap
- type MinHeap
- type Queue
- type Stack
- type TreeNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChanToSlice ¶
ChanToSlice pushes values from a channel to a slice.
func ContainString ¶
ContainString checks if the target is in a slice.
func IsLessThan1Apart ¶
IsLessThan1Apart checks if two integers are less or equal than 1 apart.
func IsMoreThan1Apart ¶
IsMoreThan1Apart checks if two integers are more than 1 apart.
func LinkedListToSlice ¶
LinkedListToSlice converts a linked list into an array of integer.
func SwapString ¶
SwapString two array values given their indices.
Types ¶
type List ¶
type List struct {
// contains filtered or unexported fields
}
List implements a linked list.
func (*List) Front ¶
func (l *List) Front() interface{}
Front returns the first element of the list.
func (*List) InsertAfter ¶
func (l *List) InsertAfter(v, mark interface{})
InsertAfter inserts an element after another.
func (*List) InsertBefore ¶
func (l *List) InsertBefore(v, mark interface{})
InsertBefore inserts an element before another.
func (*List) MoveAfter ¶
func (l *List) MoveAfter(v, mark interface{})
MoveAfter moves an element after another.
func (*List) MoveBack ¶
func (l *List) MoveBack(v interface{})
MoveBack moves an element to the back of the list.
func (*List) MoveBefore ¶
func (l *List) MoveBefore(v, mark interface{})
MoveBefore moves an element before another.
func (*List) MoveFront ¶
func (l *List) MoveFront(v interface{})
MoveFront moves an element to the front of the list.
func (*List) PushBack ¶
func (l *List) PushBack(v interface{}) interface{}
PushBack inserts an element at the back of the list.
func (*List) PushFront ¶
func (l *List) PushFront(v interface{}) interface{}
PushFront inserts an element at the front of the list.
func (*List) RemoveBack ¶
func (l *List) RemoveBack() interface{}
RemoveBack removes an element at the back of the list.
func (*List) RemoveFront ¶
func (l *List) RemoveFront() interface{}
RemoveFront removes an element at the front of the list.
type MaxHeap ¶
type MaxHeap struct {
// contains filtered or unexported fields
}
MaxHeap represents a max heap data structure.
type MinHeap ¶
type MinHeap struct {
// contains filtered or unexported fields
}
MinHeap represents a min heap data structure.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue implements a queue data structure.
func (*Queue) Back ¶
func (q *Queue) Back() interface{}
Back returns the element in the back of the queue.
func (*Queue) Front ¶
func (q *Queue) Front() interface{}
Front returns the element in the front of the queue.
func (*Queue) Pop ¶
func (q *Queue) Pop() interface{}
Pop removes and returns the element in the front of the queue.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack implements a stack data structure.
func (*Stack) Pop ¶
func (q *Stack) Pop() interface{}
Pop removes and returns the element on top of the stack.