link_list

package
v0.0.0-...-1605a13 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DLL

type DLL struct {
	sync.RWMutex // Read-Write lock to ensure safe concurrent access.
	// contains filtered or unexported fields
}

DLL represents a doubly linked list with root, last node, and a read-write lock.

func (*DLL) Delete

func (dll *DLL) Delete(node *Node)

Delete removes a given node from the doubly linked list. It locks the DLL to prevent race conditions during deletion.

func (*DLL) GetLRUFreeSpace

func (dll *DLL) GetLRUFreeSpace(lru *Node, blockSize int) []byte

GetLRUFreeSpace returns a slice of bytes representing the free space in the LRU node. It locks the list to avoid concurrent modification during the operation.

func (*DLL) Inset

func (dll *DLL) Inset(value Value) *Node

Inset adds a new node with the given value to the doubly linked list. It locks the DLL to prevent race conditions while modifying the list.

func (*DLL) LastNode

func (dll *DLL) LastNode() *Node

LastNode returns the last node in the doubly linked list.

func (*DLL) PopLastFreeSpace

func (dll *DLL) PopLastFreeSpace(blockSize int) ([]byte, string, bool)

func (*DLL) Read

func (dll *DLL) Read(node *Node)

Read moves a node to the front of the doubly linked list (making it the new root). It locks the DLL to prevent concurrent modification.

func (*DLL) ReadAll

func (dll *DLL) ReadAll()

ReadAll traverses the entire doubly linked list from root to last, printing each node's value.

func (*DLL) ReadBack

func (dll *DLL) ReadBack()

ReadBack traverses the entire doubly linked list from last to root, printing each node's value.

func (*DLL) Remove

func (dll *DLL) Remove()

Remove deletes the last node from the doubly linked list. It locks the DLL to ensure safe modification of the list.

type Node

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

Node represents a node in the doubly linked list.

func (*Node) GetKey

func (n *Node) GetKey() string

GetKey returns the key of the value stored in the node.

func (*Node) GetPointer

func (n *Node) GetPointer() unsafe.Pointer

type Value

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

Value represents the data in a node, containing a pointer and a key.

func NewValue

func NewValue(pointer unsafe.Pointer, key string) Value

NewValue creates a new Value with the provided pointer and key.

Jump to

Keyboard shortcuts

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