@@ -92,6 +92,11 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for BTree<K, V> {
92
92
}
93
93
}
94
94
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
+ }
95
100
96
101
impl < K : TotalOrd , V : TotalEq > TotalEq for BTree < K , V > {
97
102
///Testing equality on BTrees by comparing the root.
@@ -100,6 +105,12 @@ impl<K: TotalOrd, V: TotalEq> TotalEq for BTree<K, V> {
100
105
}
101
106
}
102
107
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
+
103
114
impl < K : TotalOrd , V : TotalEq > TotalOrd for BTree < K , V > {
104
115
///Returns an ordering based on the root nodes of each BTree.
105
116
fn cmp ( & self , other : & BTree < K , V > ) -> Ordering {
@@ -191,6 +202,12 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for Node<K, V> {
191
202
}
192
203
}
193
204
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
+
194
211
impl < K : TotalOrd , V : TotalEq > TotalEq for Node < K , V > {
195
212
///Returns whether two nodes are equal based on the keys of each element.
196
213
///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> {
215
232
}
216
233
}
217
234
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
+
218
241
impl < K : TotalOrd , V : TotalEq > TotalOrd for Node < K , V > {
219
242
///Implementation of TotalOrd for Nodes.
220
243
fn cmp ( & self , other : & Node < K , V > ) -> Ordering {
@@ -380,13 +403,25 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for Leaf<K, V> {
380
403
}
381
404
}
382
405
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
+
383
412
impl < K : TotalOrd , V : TotalEq > TotalEq for Leaf < K , V > {
384
413
///Implementation of equals function for leaves that compares LeafElts.
385
414
fn equals ( & self , other : & Leaf < K , V > ) -> bool {
386
415
self . elts . equals ( & other. elts )
387
416
}
388
417
}
389
418
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
+
390
425
impl < K : TotalOrd , V : TotalEq > TotalOrd for Leaf < K , V > {
391
426
///Returns an ordering based on the first element of each Leaf.
392
427
fn cmp ( & self , other : & Leaf < K , V > ) -> Ordering {
@@ -602,13 +637,25 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for Branch<K, V> {
602
637
}
603
638
}
604
639
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
+
605
646
impl < K : TotalOrd , V : TotalEq > TotalEq for Branch < K , V > {
606
647
///Equals function for Branches--compares all the elements in each branch
607
648
fn equals ( & self , other : & Branch < K , V > ) -> bool {
608
649
self . elts . equals ( & other. elts )
609
650
}
610
651
}
611
652
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
+
612
659
impl < K : TotalOrd , V : TotalEq > TotalOrd for Branch < K , V > {
613
660
///Compares the first elements of two branches to determine an ordering
614
661
fn cmp ( & self , other : & Branch < K , V > ) -> Ordering {
@@ -663,13 +710,25 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for LeafElt<K, V> {
663
710
}
664
711
}
665
712
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
+
666
719
impl < K : TotalOrd , V : TotalEq > TotalEq for LeafElt < K , V > {
667
720
///TotalEq for LeafElts
668
721
fn equals ( & self , other : & LeafElt < K , V > ) -> bool {
669
722
self . key . equals ( & other. key ) && self . value . equals ( & other. value )
670
723
}
671
724
}
672
725
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
+
673
732
impl < K : TotalOrd , V : TotalEq > TotalOrd for LeafElt < K , V > {
674
733
///Returns an ordering based on the keys of the LeafElts.
675
734
fn cmp ( & self , other : & LeafElt < K , V > ) -> Ordering {
@@ -705,13 +764,25 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for BranchElt<K, V> {
705
764
}
706
765
}
707
766
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
+
708
773
impl < K : TotalOrd , V : TotalEq > TotalEq for BranchElt < K , V > {
709
774
///TotalEq for BranchElts
710
775
fn equals ( & self , other : & BranchElt < K , V > ) -> bool {
711
776
self . key . equals ( & other. key ) &&self . value . equals ( & other. value )
712
777
}
713
778
}
714
779
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
+
715
786
impl < K : TotalOrd , V : TotalEq > TotalOrd for BranchElt < K , V > {
716
787
///Fulfills TotalOrd for BranchElts
717
788
fn cmp ( & self , other : & BranchElt < K , V > ) -> Ordering {
0 commit comments