sorting

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerDistance

type PeerDistance struct {
	peer.ID
	Distance *big.Int
}

PeerDistance is a composite struct on top of a peer ID that also contains the kad distance measured against the current peer and held as a big.Int

type PeerDistances

type PeerDistances []*PeerDistance

PeerDistances represents a sortable peerDistance slice

func (PeerDistances) Len

func (pd PeerDistances) Len() int

Len returns the length of this slice

func (PeerDistances) Less

func (pd PeerDistances) Less(i, j int) bool

Less is used in sorting and returns if i-th element is less than j-th element

func (PeerDistances) Swap

func (pd PeerDistances) Swap(i, j int)

Swap is used in sorting and swaps the values between the i-th position with the one found on j-th position

type SortedID

type SortedID struct {
	ID       peer.ID
	Key      []byte
	Shard    uint32
	Distance *big.Int
}

SortedID contains the peer data

type SortedList

type SortedList struct {
	Ref   SortedID
	Peers []SortedID
}

SortedList holds a sorted list of elements in respect with the reference value

func (*SortedList) Len

func (sl *SortedList) Len() int

Len is the number of elements in the collection.

func (*SortedList) Less

func (sl *SortedList) Less(i int, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (*SortedList) SortedPeers

func (sl *SortedList) SortedPeers() []peer.ID

SortedPeers get the orted list of peers

func (*SortedList) Swap

func (sl *SortedList) Swap(i int, j int)

Swap swaps the elements with indexes i and j.

Jump to

Keyboard shortcuts

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