1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//! Circular (ring) sequence operations for Rust slices.
//!
//! Reach the circular API by calling [`AsCircular::circular`] on any slice,
//! [`Vec<T>`](alloc::vec::Vec), array, or [`Box<[T]>`](alloc::boxed::Box).
//! The returned [`Circular`] wrapper is the single home for every circular
//! operation; every transform it offers is lazy and allocation-free.
//!
//! # Quick start
//!
//! ```
//! use ring_seq::AsCircular;
//!
//! let r = [10, 20, 30].circular();
//!
//! // Indexing wraps in both directions
//! assert_eq!(*r.apply(4), 20);
//! assert_eq!(*r.apply(-1), 30);
//!
//! // Reindexed views — no allocation
//! let rotated: Vec<_> = r.rotate_right(1).iter().copied().collect();
//! assert_eq!(rotated, vec![30, 10, 20]);
//!
//! // Comparisons up to rotation/reflection
//! assert!(r.is_rotation_of(&[20, 30, 10]));
//! assert!(r.is_reflection_of(&[10, 30, 20]));
//!
//! // Canonical (necklace) form — uses Booth's O(n)
//! assert_eq!(r.canonical(), vec![10, 20, 30]);
//!
//! // Lazy iterators of views
//! let firsts: Vec<i32> = r.rotations().map(|v| *v.apply(0)).collect();
//! assert_eq!(firsts, vec![10, 20, 30]);
//! ```
//!
//! # `no_std`
//!
//! The crate is `#![no_std]`. The default `alloc` feature enables the
//! methods that return owned collections ([`Circular::to_vec`],
//! [`Circular::canonical`], [`Circular::bracelet`],
//! [`Circular::symmetry_indices`],
//! [`Circular::reflectional_symmetry_axes`]) and the implementation of
//! [`Circular::canonical_index`] (Booth's algorithm allocates internally).
//! With `--no-default-features` the wrapper and its element/view iterators
//! remain available and depend only on `core`.
extern crate alloc;
pub use ;
// ============================================================================
// AxisLocation
// ============================================================================
/// A location on a circular sequence where a reflectional-symmetry axis
/// passes.
///
/// # Variants
///
/// * [`Vertex`](AxisLocation::Vertex) — the axis passes through the
/// element at the given index.
/// * [`Edge`](AxisLocation::Edge) — the axis passes between two
/// consecutive elements.