File tree 4 files changed +21
-7
lines changed
4 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 1
1
2
2
[package ]
3
3
name = " im_ternary_tree"
4
- version = " 0.0.15 "
4
+ version = " 0.0.16 "
5
5
edition = " 2021"
6
6
authors = [
" jiyinyiyong <[email protected] >" ]
7
7
license = " MIT"
Original file line number Diff line number Diff line change @@ -258,6 +258,20 @@ fn criterion_benchmark(c: &mut Criterion) {
258
258
}
259
259
} )
260
260
} ) ;
261
+
262
+ c. bench_function ( "first" , |b| {
263
+ let mut data = TernaryTreeList :: Empty ;
264
+
265
+ for idx in 0 ..1000 {
266
+ data = data. push ( idx)
267
+ }
268
+
269
+ b. iter ( || {
270
+ for _ in 0 ..10000 {
271
+ let _ = data. first ( ) ;
272
+ }
273
+ } )
274
+ } ) ;
261
275
}
262
276
263
277
criterion_group ! ( benches, criterion_benchmark) ;
Original file line number Diff line number Diff line change 91
91
Tree ( t) => t. ref_last ( ) ,
92
92
}
93
93
} else {
94
- self . ref_get ( idx)
94
+ self . loop_get ( idx)
95
95
}
96
96
}
97
97
@@ -492,7 +492,7 @@ where
492
492
fn next ( & mut self ) -> Option < Self :: Item > {
493
493
if self . index < self . value . len ( ) {
494
494
// println!("get: {} {}", self.value.format_inline(), self.index);
495
- let ret = self . value . ref_get ( self . index ) ;
495
+ let ret = self . value . loop_get ( self . index ) ;
496
496
self . index += 1 ;
497
497
ret
498
498
} else {
Original file line number Diff line number Diff line change @@ -1275,7 +1275,7 @@ where
1275
1275
fn next ( & mut self ) -> Option < Self :: Item > {
1276
1276
if self . index < self . value . len ( ) {
1277
1277
// println!("get: {} {}", self.value.format_inline(), self.index);
1278
- let ret = self . value . ref_get ( self . index ) ;
1278
+ let ret = self . value . loop_get ( self . index ) ;
1279
1279
self . index += 1 ;
1280
1280
Some ( ret)
1281
1281
} else {
@@ -1291,7 +1291,7 @@ impl<T: Clone + Display + Eq + PartialEq + Debug + Ord + PartialOrd + Hash> Part
1291
1291
}
1292
1292
1293
1293
for idx in 0 ..ys. len ( ) {
1294
- if self . ref_get ( idx) != ys. ref_get ( idx) {
1294
+ if self . loop_get ( idx) != ys. loop_get ( idx) {
1295
1295
return false ;
1296
1296
}
1297
1297
}
@@ -1318,7 +1318,7 @@ where
1318
1318
fn cmp ( & self , other : & Self ) -> Ordering {
1319
1319
if self . len ( ) == other. len ( ) {
1320
1320
for idx in 0 ..self . len ( ) {
1321
- match self . ref_get ( idx) . cmp ( other. ref_get ( idx) ) {
1321
+ match self . loop_get ( idx) . cmp ( other. loop_get ( idx) ) {
1322
1322
Ordering :: Equal => { }
1323
1323
a => return a,
1324
1324
}
@@ -1339,7 +1339,7 @@ where
1339
1339
1340
1340
fn index < ' b > ( & self , idx : usize ) -> & Self :: Output {
1341
1341
// println!("get: {} {}", self.format_inline(), idx);
1342
- self . ref_get ( idx)
1342
+ self . loop_get ( idx)
1343
1343
}
1344
1344
}
1345
1345
You can’t perform that action at this time.
0 commit comments