Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RDict ¶
type RDict struct {
// contains filtered or unexported fields
}
RDict is a data structure that behaves both as a map and as a ring. It is defined by a capacity, just as a ring. As more key-value pairs are added to it, it fills up until the capacity is reached. At that point, the first key in insertion order gets overwritten.
It supports only string as key type. It is not goroutine-safe.
func (*RDict) Del ¶
Del removes the key-value pair from the RDict. Returns true if the provided key was present in the RDict, false otherwise. Beware: it is O(N) in the worst case, being N the capacity of the RDict.
func (*RDict) Do ¶
Do is the API to iterate over all the RDict elements. The provided input function receives, for each element stored in RDict, the key as first argument and the corresponding value as second.
type SafeRDict ¶
type SafeRDict struct {
// contains filtered or unexported fields
}
SafeRDict is the goroutine-safe version of RDict.
func NewSafe ¶
NewSafe is the constructor for the SafeRDict. One needs to provide the capacity as sole input.
func (*SafeRDict) Del ¶
Del removes the key-value pair from the RDict. Returns true if the provided key was present in the RDict, false otherwise. Beware: it is O(N) in the worst case, being N the capacity of the SafeRDict. Locks RW.
func (*SafeRDict) Do ¶
Do is the API to iterate over all the RDict elements. The provided input function receives, for each element stored in RDict, the key as first argument and the corresponding value as second. Locks R.