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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
//! Stack-friendly buffer aliases for topology and geometry algorithms.
//!
//! The aliases in this module document the expected cardinality of common
//! intermediate collections while keeping hot paths allocation-conscious.
use ;
use crateFacetHandle;
use crate;
// =============================================================================
// ALGORITHM-SPECIFIC BUFFER TYPES
// =============================================================================
/// Size constant for operations that may affect multiple simplices during cleanup.
/// 16 provides generous headroom for duplicate removal and topology repair operations.
///
/// This constant is publicly exposed to allow external modules to derive buffer sizes
/// from it, ensuring consistent sizing across the codebase.
pub const CLEANUP_OPERATION_BUFFER_SIZE: usize = 16;
/// Collection for tracking simplices to remove during cleanup operations.
/// Most cleanup operations affect a small number of simplices.
///
/// # Optimization Rationale
///
/// - **Stack Allocation**: Up to 16 simplices (covers most cleanup scenarios)
/// - **Use Case**: Duplicate simplex removal, invalid facet cleanup
/// - **Performance**: Avoids heap allocation for typical cleanup operations
pub type SimplexRemovalBuffer = ;
/// Collection for tracking Delaunay violations during iterative refinement.
/// Most violation checks find a small number of violating simplices.
///
/// # Optimization Rationale
///
/// - **Stack Allocation**: Up to 16 simplices (covers most violation scenarios)
/// - **Use Case**: Iterative cavity refinement, Delaunay validation
/// - **Performance**: Avoids heap allocation in hot paths during insertion
/// - **Typical Size**: 0-4 violations in well-conditioned triangulations
pub type ViolationBuffer = ;
/// Collection for tracking simplex keys during insertion operations.
/// Most insertion operations create a small number of simplices.
///
/// # Optimization Rationale
///
/// - **Stack Allocation**: Up to 16 simplices (covers most insertion scenarios)
/// - **Use Case**: Cavity-based insertion, simplex creation tracking
/// - **Performance**: Avoids heap allocation during simplex creation
/// - **Typical Size**: 4-8 simplices in well-conditioned triangulations (D+1 for simple cavity)
pub type SimplexKeyBuffer = ;
/// Buffer for storing cavity boundary facets during insertion/removal operations.
///
/// This is used by cavity extraction and filling routines. Inline capacity 64 avoids heap
/// allocation for typical cavities while still allowing growth for large conflict regions.
pub type CavityBoundaryBuffer = ;
/// Buffer for storing simplices that share a facet.
/// Facets are incident to at most 2 simplices (one-sided=1, two-sided=2).
///
/// # Optimization Rationale
///
/// - **Stack Allocation**: Exactly 2 simplices (no heap allocation for valid triangulations)
/// - **Use Case**: Facet-to-simplices mapping validation, cavity boundary detection
/// - **Performance**: Eliminates heap allocation when invariant holds (≤2 simplices per facet)
/// - **Memory Efficiency**: 2 × 8 bytes = 16 bytes on stack per facet
///
/// # Invariant
///
/// Valid triangulations have the following facet sharing invariants:
/// - **Boundary facets**: Shared by exactly 1 simplex (hull facets)
/// - **Interior facets**: Shared by exactly 2 simplices (adjacent simplices)
/// - **Invalid**: Shared by >2 simplices (indicates TDS corruption)
///
/// # Examples
///
/// ```rust
/// use delaunay::prelude::collections::FacetSharingSimplicesBuffer;
///
/// let mut sharing_simplices: FacetSharingSimplicesBuffer = FacetSharingSimplicesBuffer::new();
/// assert!(sharing_simplices.is_empty());
/// ```
pub type FacetSharingSimplicesBuffer = ;
// =============================================================================
// SEMANTIC SIZE CONSTANTS AND TYPE ALIASES
// =============================================================================
/// Buffer sized for vertex collections in D-dimensional simplices.
/// A D-dimensional simplex has D+1 vertices, so this handles up to 7D simplices on stack.
///
/// # Use Cases
/// - Simplex vertex operations
/// - Simplex construction
/// - Geometric predicate vertex lists
pub type SimplexVertexBuffer<T> = ;
/// Buffer sized for `VertexKey` collections in validation and internal operations.
/// Handles vertex keys from a single D-dimensional simplex.
///
/// # Use Cases
/// - Validation algorithms
/// - Internal vertex key tracking
/// - Simplex vertex key collections
pub type VertexKeyBuffer = ;
/// Buffer for storing simplex neighbors (D+1 neighbors for a D-dimensional simplex).
/// Uses stack allocation for typical dimensions (2D-7D).
///
/// # Optimization Rationale
///
/// - **Stack Allocation**: D+1 neighbors fit on stack for D ≤ 7
/// - **Use Case**: Neighbor queries, neighbor assignment, validation
/// - **Performance**: Avoids heap allocation in 90%+ of cases
/// - **Memory Layout**: Better cache locality than heap-allocated Vec
///
/// # Examples
///
/// ```rust
/// use delaunay::prelude::collections::NeighborBuffer;
/// use delaunay::prelude::tds::SimplexKey;
///
/// let mut neighbors: NeighborBuffer<Option<SimplexKey>> = NeighborBuffer::new();
/// assert!(neighbors.is_empty());
/// ```
pub type NeighborBuffer<T> = ;
/// Buffer for vertex key collections from a single simplex (D+1 vertices).
/// Avoids heap allocation for typical triangulation dimensions.
///
/// # Optimization Rationale
///
/// - **Stack Allocation**: D+1 vertex keys fit on stack for D ≤ 7
/// - **Use Case**: Simplex vertex storage, validation, geometric operations
/// - **Performance**: Eliminates heap allocation for typical dimensions
/// - **Ordering**: Preserves vertex order for positional semantics
pub type SimplexVertexKeyBuffer = ;
/// Buffer for vertex UUID collections from a single simplex (D+1 vertex UUIDs).
/// Uses stack allocation to avoid heap overhead for simplex operations.
///
/// # Optimization Rationale
///
/// - **Stack Allocation**: D+1 vertex UUIDs fit on stack for D ≤ 7
/// - **Use Case**: Extracting vertex UUIDs from a simplex, validation, duplicate detection
/// - **Performance**: Avoids allocation for temporary UUID collections
/// - **Memory Efficiency**: For D=7, D+1=8 UUIDs → 16 bytes × 8 = 128 bytes on stack
pub type SimplexVertexUuidBuffer = ;
/// Buffer for periodic lattice offsets aligned with a simplex's vertex slots.
///
/// Periodic simplices store one offset per vertex slot so the inline capacity
/// matches [`SimplexVertexKeyBuffer`] and avoids a heap allocation for supported
/// small-to-medium dimensions.
pub type PeriodicOffsetBuffer<const D: usize> = ;
/// Buffer sized for Point collections in geometric operations.
/// Generic over coordinate type T and dimension D, with practical size limit.
///
/// # Use Cases
/// - Geometric predicate operations
/// - Simplex coordinate collections
/// - Temporary point storage during algorithms
pub type GeometricPointBuffer<T, const D: usize> =
;