Skip to content

Commit 401b1c7

Browse files
ericktalexcrichton
authored andcommitted
---
yaml --- r: 109743 b: refs/heads/snap-stage3 c: 8057faa h: refs/heads/master i: 109741: 134dd60 109739: e207e22 109735: 25dea10 109727: c0aa8b7 v: v3
1 parent f507ffe commit 401b1c7

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: b8ef9fd9c9f642ce7b8aed82782a1ed745d08d64
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 7c48e53c1e8c1427cbb2e827a9d43bfa36847d65
4+
refs/heads/snap-stage3: 8057faa2d320db0abdfb385ad1827f8902931cef
55
refs/heads/try: f64fdf524a434f0e5cd0bc91d09c144723f3c90d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcollections/trie.rs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -293,32 +293,46 @@ impl Mutable for TrieSet {
293293
fn clear(&mut self) { self.map.clear() }
294294
}
295295

296-
impl TrieSet {
297-
/// Create an empty TrieSet
296+
impl Set<uint> for TrieSet {
298297
#[inline]
299-
pub fn new() -> TrieSet {
300-
TrieSet{map: TrieMap::new()}
298+
fn contains(&self, value: &uint) -> bool {
299+
self.map.contains_key(value)
301300
}
302301

303-
/// Return true if the set contains a value
304302
#[inline]
305-
pub fn contains(&self, value: &uint) -> bool {
306-
self.map.contains_key(value)
303+
fn is_disjoint(&self, other: &TrieSet) -> bool {
304+
self.iter().all(|v| !other.contains(&v))
307305
}
308306

309-
/// Add a value to the set. Return true if the value was not already
310-
/// present in the set.
311307
#[inline]
312-
pub fn insert(&mut self, value: uint) -> bool {
308+
fn is_subset(&self, other: &TrieSet) -> bool {
309+
self.iter().all(|v| other.contains(&v))
310+
}
311+
312+
#[inline]
313+
fn is_superset(&self, other: &TrieSet) -> bool {
314+
other.is_subset(self)
315+
}
316+
}
317+
318+
impl MutableSet<uint> for TrieSet {
319+
#[inline]
320+
fn insert(&mut self, value: uint) -> bool {
313321
self.map.insert(value, ())
314322
}
315323

316-
/// Remove a value from the set. Return true if the value was
317-
/// present in the set.
318324
#[inline]
319-
pub fn remove(&mut self, value: &uint) -> bool {
325+
fn remove(&mut self, value: &uint) -> bool {
320326
self.map.remove(value)
321327
}
328+
}
329+
330+
impl TrieSet {
331+
/// Create an empty TrieSet
332+
#[inline]
333+
pub fn new() -> TrieSet {
334+
TrieSet{map: TrieMap::new()}
335+
}
322336

323337
/// Visit all values in reverse order
324338
#[inline]

0 commit comments

Comments
 (0)