|
1 | 1 | # Similar to ExtrapDimSpec but for only a single dimension
|
2 | 2 | const ExtrapSpec = Union{BoundaryCondition,Tuple{BoundaryCondition,BoundaryCondition}}
|
3 | 3 |
|
4 |
| -# Macro to get create ExtrapSpec for checking if a KnotIterator has a given BC |
5 |
| -# for forward iteration |
6 |
| -macro FwdExtrapSpec(bc) |
7 |
| - :( Union{$bc,Tuple{BoundaryCondition,$bc}} ) |
8 |
| -end |
| 4 | +# Type Alias to get Boundary Condition or forward boundary conditions if |
| 5 | +# directional |
| 6 | +const FwdExtrapSpec{FwdBC} = Union{FwdBC, Tuple{BoundaryCondition, FwdBC}} |
9 | 7 |
|
10 | 8 | """
|
11 | 9 | KnotIterator{T,ET}(k::AbstractArray{T}, bc::ET)
|
@@ -132,12 +130,12 @@ iterate(iter::KnotIterator) = iterate(iter, 1)
|
132 | 130 | iterate(iter::KnotIterator, idx::Integer) = idx <= iter.nknots ? (iter.knots[idx], idx+1) : nothing
|
133 | 131 |
|
134 | 132 | # For repeating knots state is the knot index + offset value
|
135 |
| -function iterate(iter::KnotIterator{T,ET}) where {T,ET <: @FwdExtrapSpec(RepeatKnots)} |
| 133 | +function iterate(iter::KnotIterator{T,ET}) where {T,ET <: FwdExtrapSpec{RepeatKnots}} |
136 | 134 | iterate(iter, (1, zero(T)))
|
137 | 135 | end
|
138 | 136 |
|
139 | 137 | # Periodic: Iterate over knots, updating the offset each cycle
|
140 |
| -function iterate(iter::KnotIterator{T,ET}, state::Tuple) where {T, ET <: @FwdExtrapSpec(Periodic)} |
| 138 | +function iterate(iter::KnotIterator{T,ET}, state::Tuple) where {T, ET <: FwdExtrapSpec{Periodic}} |
141 | 139 | state === nothing && return nothing
|
142 | 140 | curidx, offset = state[1], state[2]
|
143 | 141 |
|
|
156 | 154 |
|
157 | 155 | # Reflect: Iterate over knots, updating the offset after a forward and backwards
|
158 | 156 | # cycle
|
159 |
| -function iterate(iter::KnotIterator{T, ET}, state) where {T, ET <: @FwdExtrapSpec(Reflect)} |
| 157 | +function iterate(iter::KnotIterator{T, ET}, state) where {T, ET <: FwdExtrapSpec{Reflect}} |
160 | 158 | state === nothing && return nothing
|
161 | 159 | curidx, offset = state[1], state[2]
|
162 | 160 |
|
|
0 commit comments