File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,32 @@ impl<T: PartialOrder> Antichain<T> {
4343 }
4444 }
4545
46+ /// Updates the `Antichain` if the element is not greater than or equal to some present element.
47+ ///
48+ /// Returns true if element is added to the set
49+ ///
50+ /// Accepts a reference to an element, which is cloned when inserting.
51+ ///
52+ /// # Examples
53+ ///
54+ ///```
55+ /// use timely::progress::frontier::Antichain;
56+ ///
57+ /// let mut frontier = Antichain::new();
58+ /// assert!(frontier.insert_ref(&2));
59+ /// assert!(!frontier.insert(3));
60+ ///```
61+ pub fn insert_ref ( & mut self , element : & T ) -> bool where T : Clone {
62+ if !self . elements . iter ( ) . any ( |x| x. less_equal ( element) ) {
63+ self . elements . retain ( |x| !element. less_equal ( x) ) ;
64+ self . elements . push ( element. clone ( ) ) ;
65+ true
66+ }
67+ else {
68+ false
69+ }
70+ }
71+
4672 /// Reserves capacity for at least additional more elements to be inserted in the given `Antichain`
4773 pub fn reserve ( & mut self , additional : usize ) {
4874 self . elements . reserve ( additional) ;
You can’t perform that action at this time.
0 commit comments