Skip to content

Commit e7a4693

Browse files
authored
Merge pull request #38 from orxfun/Use-of-Collection-constrained-PinnedVecs
Use of Collection constrained PinnedVecs
2 parents 9b5e2e8 + b630ae5 commit e7a4693

17 files changed

+92
-8
lines changed

Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "orx-linked-list"
3-
version = "3.3.0"
3+
version = "3.4.0"
44
edition = "2021"
55
authors = ["orxfun <[email protected]>"]
66
description = "A linked list implementation with unique features and an extended list of constant time methods providing high performance traversals and mutations."
@@ -11,10 +11,11 @@ categories = ["data-structures", "rust-patterns", "no-std"]
1111

1212
[dependencies]
1313
orx-pseudo-default = { version = "1.4", default-features = false }
14-
orx-pinned-vec = "3.11"
15-
orx-split-vec = "3.11"
16-
orx-fixed-vec = "3.11"
17-
orx-selfref-col = "2.3"
14+
orx-pinned-vec = "3.12"
15+
orx-fixed-vec = "3.12"
16+
orx-split-vec = "3.12"
17+
orx-selfref-col = "2.5"
18+
orx-iterable = { version = "1.1.1", default-features = false }
1819

1920
[dev-dependencies]
2021
clap = { version = "4.5.27", features = ["derive"] }
@@ -24,7 +25,7 @@ rand_chacha = "0.3.1"
2425
test-case = "3.3.1"
2526

2627
[features]
27-
default = ["validation"]
28+
default = []
2829
validation = []
2930

3031
[[bench]]

src/list/common_traits/index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use crate::{
22
type_aliases::OOB, variant::Doubly, DoublyEnds, DoublyEndsMut, DoublyIdx, List, ListSlice,
33
ListSliceMut, Singly, SinglyEnds, SinglyEndsMut, SinglyIdx,
44
};
5+
use core::ops::{Index, IndexMut};
56
use orx_pinned_vec::PinnedVec;
67
use orx_selfref_col::{MemoryPolicy, Node};
7-
use std::ops::{Index, IndexMut};
88

99
// doubly
1010

src/list/mutate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::List;
22
use crate::variant::ListVariant;
3-
use orx_pinned_vec::PinnedVec;
3+
use orx_iterable::CollectionMut;
44
use orx_selfref_col::MemoryPolicy;
55

66
impl<V, M> List<V, M>

tests/append.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ fn append_front_doubly<M: MemoryPolicy<Doubly<char>>>(mut list: List<Doubly<char
1919
other.push_back('j');
2020

2121
list.append_front(other);
22+
#[cfg(feature = "validation")]
2223
list.validate();
2324
assert!(list.eq_to_iter_vals(['f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e']));
2425

@@ -44,6 +45,7 @@ fn append_back_doubly<M: MemoryPolicy<Doubly<char>>>(mut list: List<Doubly<char>
4445
other.push_back('j');
4546

4647
list.append_back(other);
48+
#[cfg(feature = "validation")]
4749
list.validate();
4850
assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']));
4951

tests/clone.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ fn clone_singly() {
88
let list = singly::new_singly(&mut doubly::rng(), 40, 50);
99
let clone = list.clone();
1010

11+
#[cfg(feature = "validation")]
1112
clone.validate();
1213

1314
assert!(list.eq_to_iter_refs(clone.iter()));
@@ -18,6 +19,7 @@ fn clone_doubly() {
1819
let list = doubly::new_doubly(&mut doubly::rng(), 40, 50);
1920
let clone = list.clone();
2021

22+
#[cfg(feature = "validation")]
2123
clone.validate();
2224

2325
assert!(list.eq_to_iter_refs(clone.iter()));

tests/from_iter.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use test_case::test_matrix;
55
fn from_iter_singly(len: usize) {
66
let iter = (0..len).map(|i| i.to_string());
77
let list: SinglyList<_> = iter.collect();
8+
#[cfg(feature = "validation")]
89
list.validate();
910

1011
match len {
@@ -27,6 +28,7 @@ fn from_iter_singly(len: usize) {
2728
fn from_iter_doubly(len: usize) {
2829
let iter = (0..len).map(|i| i.to_string());
2930
let list: DoublyList<_> = iter.collect();
31+
#[cfg(feature = "validation")]
3032
list.validate();
3133

3234
match len {

tests/insert.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ fn insert_doubly<M: MemoryPolicy<Doubly<char>>>(
4141
false => list.try_insert_prev_to(&indices[idx], 'f'),
4242
}
4343
.unwrap();
44+
#[cfg(feature = "validation")]
4445
list.validate();
4546

4647
assert!(list.eq_to_iter_vals(vec.iter().copied()));
@@ -60,6 +61,7 @@ fn insert_doubly_oob(idx: usize, next_to: bool) {
6061

6162
let mut vec = vec!['a', 'b', 'c', 'd', 'e'];
6263
vec.remove(idx);
64+
#[cfg(feature = "validation")]
6365
list.validate();
6466

6567
let idx = match idx {
@@ -70,6 +72,7 @@ fn insert_doubly_oob(idx: usize, next_to: bool) {
7072
_ => 4,
7173
};
7274
let _ = list.try_remove(&indices[idx]);
75+
#[cfg(feature = "validation")]
7376
list.validate();
7477
assert!(list.eq_to_iter_vals(vec.iter().copied()));
7578

tests/insert_at.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ use test_case::test_matrix;
77
])]
88
fn insert_at_singly<M: MemoryPolicy<Singly<char>>>(mut list: List<Singly<char>, M>) {
99
list.insert_at(0, 'a');
10+
#[cfg(feature = "validation")]
1011
list.validate();
1112
assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'd']));
1213

1314
list.insert_at(4, 'e');
15+
#[cfg(feature = "validation")]
1416
list.validate();
1517
assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'd', 'e']));
1618

1719
list.insert_at(3, 'x');
20+
#[cfg(feature = "validation")]
1821
list.validate();
1922
assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'x', 'd', 'e']));
2023
}
@@ -32,14 +35,17 @@ fn insert_at_singly_oob() {
3235
])]
3336
fn insert_at_doubly<M: MemoryPolicy<Doubly<char>>>(mut list: List<Doubly<char>, M>) {
3437
list.insert_at(0, 'a');
38+
#[cfg(feature = "validation")]
3539
list.validate();
3640
assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'd']));
3741

3842
list.insert_at(4, 'e');
43+
#[cfg(feature = "validation")]
3944
list.validate();
4045
assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'd', 'e']));
4146

4247
list.insert_at(3, 'x');
48+
#[cfg(feature = "validation")]
4349
list.validate();
4450
assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'x', 'd', 'e']));
4551
}
@@ -57,14 +63,17 @@ fn insert_at_doubly_oob() {
5763
])]
5864
fn insert_at_from_back_doubly<M: MemoryPolicy<Doubly<char>>>(mut list: List<Doubly<char>, M>) {
5965
list.insert_at_from_back(0, 'e');
66+
#[cfg(feature = "validation")]
6067
list.validate();
6168
assert!(list.eq_to_iter_vals(['b', 'c', 'd', 'e']));
6269

6370
list.insert_at_from_back(4, 'a');
71+
#[cfg(feature = "validation")]
6472
list.validate();
6573
assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'd', 'e']));
6674

6775
list.insert_at_from_back(2, 'x');
76+
#[cfg(feature = "validation")]
6877
list.validate();
6978
assert!(list.eq_to_iter_vals(['a', 'b', 'c', 'x', 'd', 'e']));
7079
}

tests/iter_from.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ fn iter_from_singly() {
2323

2424
let vec_slice = &vec[index_of_42..];
2525
let mut list_slice = list.iter_from(&idx42);
26+
#[cfg(feature = "validation")]
2627
list.validate();
2728

2829
for x in vec_slice {
@@ -60,6 +61,7 @@ fn iter_from_doubly() {
6061

6162
let vec_slice = &vec[index_of_42..];
6263
let mut list_slice = list.iter_from(&idx42);
64+
#[cfg(feature = "validation")]
6365
list.validate();
6466

6567
for x in vec_slice {
@@ -97,6 +99,7 @@ fn iter_backward_from_doubly() {
9799

98100
let vec_slice = &vec[0..=index_of_42];
99101
let mut list_slice = list.iter_backward_from(&idx42);
102+
#[cfg(feature = "validation")]
100103
list.validate();
101104

102105
for x in vec_slice.iter().rev() {

tests/list_move_next_to.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fn list_move_next_to_front() {
1616
let mut vec: Vec<_> = (0..n).into_iter().filter(|x| x != &i).collect();
1717
vec.insert(1, i);
1818

19+
#[cfg(feature = "validation")]
1920
list.validate();
2021
assert!(list.eq_to_iter_refs(&vec));
2122
}
@@ -33,6 +34,7 @@ fn list_move_next_to_back() {
3334

3435
dbg!(i, &vec, list.iter().collect::<Vec<_>>());
3536

37+
#[cfg(feature = "validation")]
3638
list.validate();
3739
assert!(list.eq_to_iter_refs(&vec));
3840
}
@@ -42,16 +44,19 @@ fn list_move_next_to_back() {
4244
fn list_move_next_front_prev_to_arbitrary() {
4345
let (mut list, idx) = list_and_indices(5);
4446
list.move_next_to(&idx[0], &idx[2]);
47+
#[cfg(feature = "validation")]
4548
list.validate();
4649
assert!(list.eq_to_iter_vals([1, 2, 0, 3, 4]));
4750

4851
let (mut list, idx) = list_and_indices(5);
4952
list.move_next_to(&idx[0], &idx[3]);
53+
#[cfg(feature = "validation")]
5054
list.validate();
5155
assert!(list.eq_to_iter_vals([1, 2, 3, 0, 4]));
5256

5357
let (mut list, idx) = list_and_indices(5);
5458
list.move_next_to(&idx[0], &idx[4]);
59+
#[cfg(feature = "validation")]
5560
list.validate();
5661
assert!(list.eq_to_iter_vals([1, 2, 3, 4, 0]));
5762
}
@@ -60,16 +65,19 @@ fn list_move_next_front_prev_to_arbitrary() {
6065
fn list_move_next_back_prev_to_arbitrary() {
6166
let (mut list, idx) = list_and_indices(5);
6267
list.move_next_to(&idx[4], &idx[2]);
68+
#[cfg(feature = "validation")]
6369
list.validate();
6470
assert!(list.eq_to_iter_vals([0, 1, 2, 4, 3]));
6571

6672
let (mut list, idx) = list_and_indices(5);
6773
list.move_next_to(&idx[4], &idx[0]);
74+
#[cfg(feature = "validation")]
6875
list.validate();
6976
assert!(list.eq_to_iter_vals([0, 4, 1, 2, 3]));
7077

7178
let (mut list, idx) = list_and_indices(5);
7279
list.move_next_to(&idx[4], &idx[1]);
80+
#[cfg(feature = "validation")]
7381
list.validate();
7482
assert!(list.eq_to_iter_vals([0, 1, 4, 2, 3]));
7583
}
@@ -78,16 +86,19 @@ fn list_move_next_back_prev_to_arbitrary() {
7886
fn list_move_next_to_arbitrary() {
7987
let (mut list, idx) = list_and_indices(5);
8088
list.move_next_to(&idx[3], &idx[2]);
89+
#[cfg(feature = "validation")]
8190
list.validate();
8291
assert!(list.eq_to_iter_vals([0, 1, 2, 3, 4]));
8392

8493
let (mut list, idx) = list_and_indices(5);
8594
list.move_next_to(&idx[3], &idx[0]);
95+
#[cfg(feature = "validation")]
8696
list.validate();
8797
assert!(list.eq_to_iter_vals([0, 3, 1, 2, 4]));
8898

8999
let (mut list, idx) = list_and_indices(5);
90100
list.move_next_to(&idx[1], &idx[3]);
101+
#[cfg(feature = "validation")]
91102
list.validate();
92103
assert!(list.eq_to_iter_vals([0, 2, 3, 1, 4]));
93104
}

0 commit comments

Comments
 (0)