Documentation ¶
Index ¶
- Constants
- func InsertAfter[T comparable](nodeBefore *Node[T], nodeAfter *Node[T])
- func RemoveAfter[T comparable](node *Node[T])
- type Animal
- type AnimalShelter
- type Cat
- type ComparableStack
- type Dog
- type IntThreeStack
- type MinStack
- type MinStack2
- type MyQueue
- type Node
- func AppendNode[T comparable](list *Node[T], node *Node[T]) *Node[T]
- func CreateNode[T comparable](data T) *Node[T]
- func RemoveAllNodesWithValue[T comparable](list *Node[T], data T) *Node[T]
- func RemoveFirstNodeWithValue[T comparable](list *Node[T], data T) *Node[T]
- func RemoveNodesWithValueUsingStrategy[T comparable](list *Node[T], data T, strategy RemoveStrategy) *Node[T]
- func ReverseList[T comparable](list *Node[T]) *Node[T]
- func SearchNodeIteratively[T comparable](list *Node[T], data T) *Node[T]
- func SearchNodeRecursively[T comparable](list *Node[T], data T) *Node[T]
- type Queue
- type RemoveStrategy
- type SortedStack
- type Stack
- type StackOfStacks
- type ThreeStack
- type TimestampedNode
Constants ¶
const ( RemoveFirstStrategy = iota RemoveAllStrategy )
Variables ¶
This section is empty.
Functions ¶
func InsertAfter ¶
func InsertAfter[T comparable](nodeBefore *Node[T], nodeAfter *Node[T])
func RemoveAfter ¶
func RemoveAfter[T comparable](node *Node[T])
Types ¶
type AnimalShelter ¶
type AnimalShelter struct {
// contains filtered or unexported fields
}
type ComparableStack ¶
func (*ComparableStack[T]) Sort ¶
func (left *ComparableStack[T]) Sort()
type IntThreeStack ¶
type IntThreeStack ThreeStack[uint32]
func (*IntThreeStack) IsEmpty ¶
func (ts *IntThreeStack) IsEmpty(stack byte) bool
type MyQueue ¶
type MyQueue[T comparable] struct { // contains filtered or unexported fields }
type Node ¶
type Node[T comparable] struct { // contains filtered or unexported fields }
func AppendNode ¶
func AppendNode[T comparable](list *Node[T], node *Node[T]) *Node[T]
func CreateNode ¶
func CreateNode[T comparable](data T) *Node[T]
func RemoveAllNodesWithValue ¶
func RemoveAllNodesWithValue[T comparable](list *Node[T], data T) *Node[T]
func RemoveFirstNodeWithValue ¶
func RemoveFirstNodeWithValue[T comparable](list *Node[T], data T) *Node[T]
func RemoveNodesWithValueUsingStrategy ¶
func RemoveNodesWithValueUsingStrategy[T comparable](list *Node[T], data T, strategy RemoveStrategy) *Node[T]
func ReverseList ¶
func ReverseList[T comparable](list *Node[T]) *Node[T]
func SearchNodeIteratively ¶
func SearchNodeIteratively[T comparable](list *Node[T], data T) *Node[T]
func SearchNodeRecursively ¶
func SearchNodeRecursively[T comparable](list *Node[T], data T) *Node[T]
type Queue ¶
type Queue[T comparable] struct { // contains filtered or unexported fields }
type RemoveStrategy ¶
type RemoveStrategy int8
type SortedStack ¶
Write a program to sort a stack such that the smallest items are on the top. You can use an additional temporary stack, but you may not copy the elements into any other data structure (such as an array). The stack supports the following operations: push, pop, peek, and isEmpty.
I could simply push the element if the top of the stack is ermpty or equal or greater than the pushed value. If the top of the stack is smaller, I pop from that stack and I push to the temp stack until the top of the stack is empty or greater than or equal to the pushed value, and then push the given value, and then pop from the temp stack to the stack until the temp stack is empty.
Otherwise, pop, peek, and isEmpty are all the same as a normal stack.
func (*SortedStack[T]) Push ¶
func (s *SortedStack[T]) Push(v T)
type Stack ¶
type Stack[T comparable] struct { // contains filtered or unexported fields }
type StackOfStacks ¶
type StackOfStacks[T comparable] struct { // contains filtered or unexported fields }
func (*StackOfStacks[T]) IsEmpty ¶
func (ss *StackOfStacks[T]) IsEmpty() bool
func (*StackOfStacks[T]) Peek ¶
func (ss *StackOfStacks[T]) Peek() (T, bool)
func (*StackOfStacks[T]) Pop ¶
func (ss *StackOfStacks[T]) Pop() (T, bool)
func (*StackOfStacks[T]) PopAt ¶
func (ss *StackOfStacks[T]) PopAt(stack int) (T, bool)
func (*StackOfStacks[T]) Push ¶
func (ss *StackOfStacks[T]) Push(v T)
type ThreeStack ¶
type ThreeStack[T comparable] struct { // contains filtered or unexported fields }
func (*ThreeStack[T]) IsEmpty ¶
func (ts *ThreeStack[T]) IsEmpty(stack int) bool
func (*ThreeStack[T]) Peek ¶
func (ts *ThreeStack[T]) Peek(stack int) (T, error)
func (*ThreeStack[T]) Pop ¶
func (ts *ThreeStack[T]) Pop(stack int) (T, error)
func (*ThreeStack[T]) Push ¶
func (ts *ThreeStack[T]) Push(stack int, value T) error
type TimestampedNode ¶
type TimestampedNode[T comparable] struct { // contains filtered or unexported fields }
func CreateTimestampedNode ¶
func CreateTimestampedNode[T comparable](value T, timestamp int64) *TimestampedNode[T]
Source Files ¶
- animal_shelter.go
- delete_middle_node.go
- detect_lists_intersection.go
- find_circular_list_head.go
- palindrome.go
- partition.go
- queue_using_2stacks.go
- queues.go
- remote_duplicates.go
- return_kth_last.go
- sorted_stack.go
- stack_min.go
- stack_of_stacks.go
- stack_sorting.go
- stacks.go
- std_linkedlists.go
- sum_lists.go
- three_stack.go