Skip to content

Commit f6b9487

Browse files
committed
Added is_full to IndexSet
1 parent 2ef05ed commit f6b9487

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
- Added `is_full`, `recent_index`, `oldest`, and `oldest_index` to `HistoryBuffer`
1515
- Added `is_full` to `BinaryHeap`
1616
- Added `is_full` to `IndexMap`
17+
- Added `is_full` to `IndexSet`
1718
- Added infallible conversions from arrays to `Vec`.
1819
- Added `Vec::spare_capacity_mut`.
1920
- Added `Extend` impls for `Deque`.

src/indexset.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,25 @@ impl<T, S, const N: usize> IndexSet<T, S, N> {
180180
self.map.is_empty()
181181
}
182182

183+
/// Returns `true` if the set is full.
184+
///
185+
/// # Examples
186+
///
187+
/// ```
188+
/// use heapless::FnvIndexSet;
189+
///
190+
/// let mut v: FnvIndexSet<_, 4> = FnvIndexSet::new();
191+
/// assert!(!v.is_full());
192+
/// v.insert(1).unwrap();
193+
/// v.insert(2).unwrap();
194+
/// v.insert(3).unwrap();
195+
/// v.insert(4).unwrap();
196+
/// assert!(v.is_full());
197+
/// ```
198+
pub fn is_full(&self) -> bool {
199+
self.map.is_full()
200+
}
201+
183202
/// Clears the set, removing all values.
184203
///
185204
/// # Examples

0 commit comments

Comments
 (0)