@@ -144,30 +144,6 @@ function rand_nbr(rng, grid::CartesianGridRej, site::Int)
144144 end
145145end
146146
147- # neighbor sampling is iterator-based
148- struct CartesianGridIter{N, T}
149- dims:: NTuple{N, Int}
150- nums_neighbors:: Vector{Int8}
151- CI:: CartesianIndices{N, T}
152- LI:: LinearIndices{N, T}
153- offsets:: Vector{CartesianIndex{N}}
154- end
155- function CartesianGridIter (dims:: Tuple )
156- dim = length (dims)
157- CI = CartesianIndices (dims)
158- LI = LinearIndices (dims)
159- offsets = potential_offsets (dim)
160- nums_neighbors = Int8[count (x -> x + CI[site] in CI, offsets) for site in 1 : prod (dims)]
161- CartesianGridIter (dims, nums_neighbors, CI, LI, offsets)
162- end
163- CartesianGridIter (dims) = CartesianGridIter (Tuple (dims))
164- function CartesianGridIter (dimension, linear_size:: Int )
165- CartesianGridIter ([linear_size for i in 1 : dimension])
166- end
167- function rand_nbr (rng, grid:: CartesianGridIter , site:: Int )
168- nth_nbr (grid, site, rand (rng, 1 : outdegree (grid, site)))
169- end
170-
171147function Base. show (io:: IO , :: MIME"text/plain" ,
172148 grid:: CartesianGridRej )
173149 println (io, " A Cartesian grid with dimensions $(grid. dims) " )
0 commit comments