pub trait Api<M, S>{
type K: Key;
// Required methods
fn add(&self, member: impl Into<ArcM<Self::K, M>>, score: S) -> bool;
fn rm(&self, member: impl Borrow<Self::K>) -> bool;
fn rm_range_by_rank(&self, range: impl RangeBounds<usize>) -> usize;
fn score(&self, member: impl Borrow<Self::K>) -> Option<S>;
fn rank(&self, member: impl Borrow<Self::K>) -> Option<usize>;
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn range(&self, range: impl RangeBounds<usize>) -> Vec<ArcM<Self::K, M>>;
fn range_with_scores(
&self,
range: impl RangeBounds<usize>,
) -> Vec<(ArcM<Self::K, M>, S)>;
fn get(&self, rank: usize) -> Option<ArcM<Self::K, M>>;
fn get_with_score(&self, rank: usize) -> Option<(ArcM<Self::K, M>, S)>;
// Provided method
fn card(&self) -> usize { ... }
}Expand description
The public API for the Zset. Zset 的公共 API。
Required Associated Types§
Required Methods§
Sourcefn add(&self, member: impl Into<ArcM<Self::K, M>>, score: S) -> bool
fn add(&self, member: impl Into<ArcM<Self::K, M>>, score: S) -> bool
Adds the specified member with the specified score to the sorted set.
If the member is already a member of the sorted set, the score is updated.
Returns true if the score was updated, false if a new member was added.
将指定的成员和分数添加到排序集合中。
如果成员已经是排序集合的成员,则更新其分数。
如果分数被更新,则返回 true;如果是新成员,则返回 false。
Sourcefn rm(&self, member: impl Borrow<Self::K>) -> bool
fn rm(&self, member: impl Borrow<Self::K>) -> bool
Removes the specified member from the sorted set. 从排序集合中移除指定的成员。
Sourcefn rm_range_by_rank(&self, range: impl RangeBounds<usize>) -> usize
fn rm_range_by_rank(&self, range: impl RangeBounds<usize>) -> usize
Removes a range of members in the sorted set, with scores ordered from low to high.
The range is a 0-based.
Returns the number of members removed.
按排名(0-based)从低到高,删除排序集合中指定范围的成员。
返回被删除的成员数量。
Sourcefn score(&self, member: impl Borrow<Self::K>) -> Option<S>
fn score(&self, member: impl Borrow<Self::K>) -> Option<S>
Returns the score of the specified member. 返回指定成员的分数。
Sourcefn rank(&self, member: impl Borrow<Self::K>) -> Option<usize>
fn rank(&self, member: impl Borrow<Self::K>) -> Option<usize>
Returns the 0-based rank of the member in the sorted set, with scores ordered from low to high. 返回成员在排序集合中的排名(0-based),分数从低到高排序。
Sourcefn len(&self) -> usize
fn len(&self) -> usize
Returns the number of elements in the sorted set (leninality). 返回排序集合中的元素数量(基数)。
Sourcefn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Returns true if the sorted set contains no elements.
如果排序集合为空,则返回 true。
Sourcefn range(&self, range: impl RangeBounds<usize>) -> Vec<ArcM<Self::K, M>>
fn range(&self, range: impl RangeBounds<usize>) -> Vec<ArcM<Self::K, M>>
Returns a range of members in the sorted set, with scores ordered from low to high.
The range is a 0-based, half-open interval (start..end).
返回排序集合中指定范围的成员,分数从低到高排序。
range 是一个 0-based 的半开区间 (start..end)。
Sourcefn range_with_scores(
&self,
range: impl RangeBounds<usize>,
) -> Vec<(ArcM<Self::K, M>, S)>
fn range_with_scores( &self, range: impl RangeBounds<usize>, ) -> Vec<(ArcM<Self::K, M>, S)>
Returns a range of members with their scores in the sorted set, with scores ordered from low to high.
The range is a 0-based, half-open interval (start..end).
返回排序集合中指定范围的成员及其分数,分数从低到高排序。
range 是一个 0-based 的半开区间 (start..end)。
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.