Documentation ¶
Index ¶
Constants ¶
View Source
const DefaultAlpha float64 = 1.5
Variables ¶
View Source
var ( ConstraintErr = errors.New("constraint error.") AlphaValueErr = errors.New("alpha value must be greater than zero.") )
Functions ¶
This section is empty.
Types ¶
type Scapegoat ¶
type Scapegoat[T constraints.Ordered] struct { Stats Stats // contains filtered or unexported fields }
func New ¶
func New[T constraints.Ordered](alpha float64) (*Scapegoat[T], error)
New creates a new Scapegoat instance. The parameter alpha allows flexibility in deciding how balanced the tree should be. A high alpha value results in fewer balances, making insertion quicker but lookups and deletions slower, and vice versa for a low alpha.
func (*Scapegoat[T]) Insert ¶
Insert a key into the tree. The key will not inserted if it already exists.
Click to show internal directories.
Click to hide internal directories.