1+ use std:: hash:: Hash ;
12use std:: sync:: Arc ;
23
34use data_bucket:: Link ;
@@ -9,9 +10,46 @@ mod table_secondary_index;
910
1011pub use indexset:: concurrent:: map:: BTreeMap as IndexMap ;
1112pub use indexset:: concurrent:: multimap:: BTreeMultiMap as IndexMultiMap ;
12- pub use table_secondary_index:: { Difference , TableIndex , TableSecondaryIndex } ;
13+ pub use table_secondary_index:: TableSecondaryIndex ;
1314
1415pub enum IndexType < ' a , T > {
1516 Unique ( & ' a TreeIndex < T , Link > ) ,
1617 NonUnique ( & ' a TreeIndex < T , Arc < LockFreeSet < Link > > > ) ,
1718}
19+
20+ #[ derive( Debug ) ]
21+ pub struct Difference < AvailableTypes > {
22+ pub old : AvailableTypes ,
23+ pub new : AvailableTypes ,
24+ }
25+
26+ pub trait TableIndex < T > {
27+ fn insert ( & self , value : T , link : Link ) -> Option < Link > ;
28+ fn remove ( & self , value : T , link : Link ) -> Option < ( T , Link ) > ;
29+ }
30+
31+ impl < T > TableIndex < T > for IndexMultiMap < T , Link >
32+ where
33+ T : Eq + Hash + Clone + std:: marker:: Send + std:: cmp:: Ord ,
34+ {
35+ fn insert ( & self , value : T , link : Link ) -> Option < Link > {
36+ self . insert ( value, link)
37+ }
38+
39+ fn remove ( & self , value : T , link : Link ) -> Option < ( T , Link ) > {
40+ self . remove ( & value, & link)
41+ }
42+ }
43+
44+ impl < T > TableIndex < T > for IndexMap < T , Link >
45+ where
46+ T : Eq + Hash + Clone + std:: marker:: Send + std:: cmp:: Ord ,
47+ {
48+ fn insert ( & self , value : T , link : Link ) -> Option < Link > {
49+ self . insert ( value, link)
50+ }
51+
52+ fn remove ( & self , value : T , _link : Link ) -> Option < ( T , Link ) > {
53+ self . remove ( & value)
54+ }
55+ }
0 commit comments