advanced

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DisjointSet

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

DisjointSet represents a disjoint-set data structure

func NewDisjointSet

func NewDisjointSet(size int) *DisjointSet

NewDisjointSet creates a new disjoint-set data structure

func (*DisjointSet) Connected

func (ds *DisjointSet) Connected(x, y int) bool

Connected checks if two elements are in the same set

func (*DisjointSet) Find

func (ds *DisjointSet) Find(x int) int

Find finds the representative (root) of the set containing element x Uses path compression for optimization

func (*DisjointSet) GetSetCount

func (ds *DisjointSet) GetSetCount() int

GetSetCount returns the number of disjoint sets

func (*DisjointSet) GetSize

func (ds *DisjointSet) GetSize() int

GetSize returns the total number of elements in the disjoint set

func (*DisjointSet) Union

func (ds *DisjointSet) Union(x, y int) bool

Union merges the sets containing elements x and y Uses union by rank for optimization

type LRUCache

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

LRUCache represents the LRU cache data structure

func NewLRUCache

func NewLRUCache(capacity int) *LRUCache

NewLRUCache creates a new LRU cache with the given capacity

func (*LRUCache) Clear

func (lru *LRUCache) Clear()

Clear removes all items from the cache

func (*LRUCache) Contains

func (lru *LRUCache) Contains(key interface{}) bool

Contains checks if a key exists in the cache

func (*LRUCache) Get

func (lru *LRUCache) Get(key interface{}) (interface{}, bool)

Get retrieves a value from the cache

func (*LRUCache) GetCapacity

func (lru *LRUCache) GetCapacity() int

GetCapacity returns the capacity of the cache

func (*LRUCache) GetSize

func (lru *LRUCache) GetSize() int

GetSize returns the current size of the cache

func (*LRUCache) Put

func (lru *LRUCache) Put(key, value interface{})

Put adds or updates a value in the cache

type Node

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

Node represents a node in the doubly linked list

type SkipList

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

SkipList represents the skip list data structure

func NewSkipList

func NewSkipList() *SkipList

NewSkipList creates a new skip list

func (*SkipList) Delete

func (sl *SkipList) Delete(key int) bool

Delete removes a key-value pair from the skip list

func (*SkipList) Insert

func (sl *SkipList) Insert(key int, value interface{})

Insert adds a new key-value pair to the skip list

func (*SkipList) Search

func (sl *SkipList) Search(key int) (interface{}, bool)

Search finds a value by key in the skip list

type SkipListNode

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

SkipListNode represents a node in the skip list

Jump to

Keyboard shortcuts

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