Skip to content

Commit

Permalink
Some more restructuring with update! (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortar authored Apr 14, 2024
1 parent c0d2574 commit a18804d
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 221 deletions.
7 changes: 6 additions & 1 deletion src/IteratorSampling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@ const ordworsample = OrdWORSample()

abstract type AbstractReservoirSample end
abstract type AbstractReservoirSampleMulti <: AbstractReservoirSample end
abstract type AbstractOrdReservoirSampleMulti <: AbstractReservoirSampleMulti end
abstract type AbstractWorReservoirSampleMulti <: AbstractReservoirSampleMulti end
abstract type AbstractOrdWorReservoirSampleMulti <: AbstractWorReservoirSampleMulti end
abstract type AbstractWrReservoirSampleMulti <: AbstractReservoirSampleMulti end
abstract type AbstractOrdWrReservoirSampleMulti <: AbstractWrReservoirSampleMulti end

struct AlgL end
struct AlgR end
struct AlgWRSKIP end
struct AlgARes end
struct AlgAExpJ end

const algL = AlgL()
const algR = AlgR()
const algWRSKIP = AlgWRSKIP()
const algARes = AlgARes()
const algAExpJ = AlgAExpJ()

Expand Down
9 changes: 9 additions & 0 deletions src/SortedSamplingMulti.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ function sortedindices_sample(rng, iter, n::Int; replace = false, ordered = fals
end
end

function skip_ahead_no_end(iter, state, n)
for _ in 1:n
it = iterate(iter, state)
state = it[2]
end
it = iterate(iter, state)
return it
end

function get_sorted_indices(rng, n, N, replace)
if replace == true
return sortedrandrange(rng, 1:N, n)
Expand Down
Loading

0 comments on commit a18804d

Please sign in to comment.