@@ -92,6 +92,11 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for BTree<K, V> {
9292 }
9393}
9494
95+ impl < K : TotalOrd , V : TotalEq > Eq for BTree < K , V > {
96+ fn eq ( & self , other : & BTree < K , V > ) -> bool {
97+ self . equals ( other)
98+ }
99+ }
95100
96101impl < K : TotalOrd , V : TotalEq > TotalEq for BTree < K , V > {
97102 ///Testing equality on BTrees by comparing the root.
@@ -100,6 +105,12 @@ impl<K: TotalOrd, V: TotalEq> TotalEq for BTree<K, V> {
100105 }
101106}
102107
108+ impl < K : TotalOrd , V : TotalEq > Ord for BTree < K , V > {
109+ fn lt ( & self , other : & BTree < K , V > ) -> bool {
110+ self . cmp ( other) == Less
111+ }
112+ }
113+
103114impl < K : TotalOrd , V : TotalEq > TotalOrd for BTree < K , V > {
104115 ///Returns an ordering based on the root nodes of each BTree.
105116 fn cmp ( & self , other : & BTree < K , V > ) -> Ordering {
@@ -191,6 +202,12 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for Node<K, V> {
191202 }
192203}
193204
205+ impl < K : TotalOrd , V : TotalEq > Eq for Node < K , V > {
206+ fn eq ( & self , other : & Node < K , V > ) -> bool {
207+ self . equals ( other)
208+ }
209+ }
210+
194211impl < K : TotalOrd , V : TotalEq > TotalEq for Node < K , V > {
195212 ///Returns whether two nodes are equal based on the keys of each element.
196213 ///Two nodes are equal if all of their keys are the same.
@@ -215,6 +232,12 @@ impl<K: TotalOrd, V: TotalEq> TotalEq for Node<K, V> {
215232 }
216233}
217234
235+ impl < K : TotalOrd , V : TotalEq > Ord for Node < K , V > {
236+ fn lt ( & self , other : & Node < K , V > ) -> bool {
237+ self . cmp ( other) == Less
238+ }
239+ }
240+
218241impl < K : TotalOrd , V : TotalEq > TotalOrd for Node < K , V > {
219242 ///Implementation of TotalOrd for Nodes.
220243 fn cmp ( & self , other : & Node < K , V > ) -> Ordering {
@@ -380,13 +403,25 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for Leaf<K, V> {
380403 }
381404}
382405
406+ impl < K : TotalOrd , V : TotalEq > Eq for Leaf < K , V > {
407+ fn eq ( & self , other : & Leaf < K , V > ) -> bool {
408+ self . equals ( other)
409+ }
410+ }
411+
383412impl < K : TotalOrd , V : TotalEq > TotalEq for Leaf < K , V > {
384413 ///Implementation of equals function for leaves that compares LeafElts.
385414 fn equals ( & self , other : & Leaf < K , V > ) -> bool {
386415 self . elts . equals ( & other. elts )
387416 }
388417}
389418
419+ impl < K : TotalOrd , V : TotalEq > Ord for Leaf < K , V > {
420+ fn lt ( & self , other : & Leaf < K , V > ) -> bool {
421+ self . cmp ( other) == Less
422+ }
423+ }
424+
390425impl < K : TotalOrd , V : TotalEq > TotalOrd for Leaf < K , V > {
391426 ///Returns an ordering based on the first element of each Leaf.
392427 fn cmp ( & self , other : & Leaf < K , V > ) -> Ordering {
@@ -602,13 +637,25 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for Branch<K, V> {
602637 }
603638}
604639
640+ impl < K : TotalOrd , V : TotalEq > Eq for Branch < K , V > {
641+ fn eq ( & self , other : & Branch < K , V > ) -> bool {
642+ self . equals ( other)
643+ }
644+ }
645+
605646impl < K : TotalOrd , V : TotalEq > TotalEq for Branch < K , V > {
606647 ///Equals function for Branches--compares all the elements in each branch
607648 fn equals ( & self , other : & Branch < K , V > ) -> bool {
608649 self . elts . equals ( & other. elts )
609650 }
610651}
611652
653+ impl < K : TotalOrd , V : TotalEq > Ord for Branch < K , V > {
654+ fn lt ( & self , other : & Branch < K , V > ) -> bool {
655+ self . cmp ( other) == Less
656+ }
657+ }
658+
612659impl < K : TotalOrd , V : TotalEq > TotalOrd for Branch < K , V > {
613660 ///Compares the first elements of two branches to determine an ordering
614661 fn cmp ( & self , other : & Branch < K , V > ) -> Ordering {
@@ -663,13 +710,25 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for LeafElt<K, V> {
663710 }
664711}
665712
713+ impl < K : TotalOrd , V : TotalEq > Eq for LeafElt < K , V > {
714+ fn eq ( & self , other : & LeafElt < K , V > ) -> bool {
715+ self . equals ( other)
716+ }
717+ }
718+
666719impl < K : TotalOrd , V : TotalEq > TotalEq for LeafElt < K , V > {
667720 ///TotalEq for LeafElts
668721 fn equals ( & self , other : & LeafElt < K , V > ) -> bool {
669722 self . key . equals ( & other. key ) && self . value . equals ( & other. value )
670723 }
671724}
672725
726+ impl < K : TotalOrd , V : TotalEq > Ord for LeafElt < K , V > {
727+ fn lt ( & self , other : & LeafElt < K , V > ) -> bool {
728+ self . cmp ( other) == Less
729+ }
730+ }
731+
673732impl < K : TotalOrd , V : TotalEq > TotalOrd for LeafElt < K , V > {
674733 ///Returns an ordering based on the keys of the LeafElts.
675734 fn cmp ( & self , other : & LeafElt < K , V > ) -> Ordering {
@@ -705,13 +764,25 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for BranchElt<K, V> {
705764 }
706765}
707766
767+ impl < K : TotalOrd , V : TotalEq > Eq for BranchElt < K , V > {
768+ fn eq ( & self , other : & BranchElt < K , V > ) -> bool {
769+ self . equals ( other)
770+ }
771+ }
772+
708773impl < K : TotalOrd , V : TotalEq > TotalEq for BranchElt < K , V > {
709774 ///TotalEq for BranchElts
710775 fn equals ( & self , other : & BranchElt < K , V > ) -> bool {
711776 self . key . equals ( & other. key ) &&self . value . equals ( & other. value )
712777 }
713778}
714779
780+ impl < K : TotalOrd , V : TotalEq > Ord for BranchElt < K , V > {
781+ fn lt ( & self , other : & BranchElt < K , V > ) -> bool {
782+ self . cmp ( other) == Less
783+ }
784+ }
785+
715786impl < K : TotalOrd , V : TotalEq > TotalOrd for BranchElt < K , V > {
716787 ///Fulfills TotalOrd for BranchElts
717788 fn cmp ( & self , other : & BranchElt < K , V > ) -> Ordering {
0 commit comments