-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚧 Start implementing
adjacency_matrix()
+ handling tombstone indices.
- Loading branch information
Showing
4 changed files
with
150 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Let a contiguous vector of data: | ||
1 2 3 4 5 6 7 8 9 | ||
U = [a, b, c, d, e, f, g, h, i] | ||
Let some entry be removed and replaced with "tombstones": | ||
1 2 3 4 5 6 7 8 9 | ||
V = [a, 🗙, c, d, 🗙, 🗙, g, h, 🗙] | ||
2 5 6 → (tombstone indices) | ||
Take the result of removing the tombstones to form a new contiguous vector: | ||
1 2 3 4 5 → u (current indices) | ||
W = [a, c, d, g, h] ↑ | ||
1 3 4 7 8 → w (former indices) | ||
This type keeps a O(ln(n)) mapping from `w` to `u` up to date, | ||
under the form of two lists: | ||
# Compressed sorted list of tombstone indices. | ||
t = [2, 6] # (5 and 9 elided because no data comes after them) | ||
# List of indices shifts. | ||
s = [0, 1, 2] # [1-shift after the `2` tombstone, 2-shift after the `5, 6` tombstones] | ||
* (always start with 0) | ||
To find `u` given `w`: | ||
i = find(t, w) # Find index in `t` where `w` should be inserted to keep `t` sorted. | ||
u = w - s[i - 1] | ||
""" | ||
struct DeadMap | ||
n::Int # Length of U. | ||
t::Vector{Int64} | ||
s::Vector{Int64} | ||
DeadMap(n::Int) = new(n, [], [0]) | ||
end | ||
|
||
# All methods hereafter are unchecked and assume consistency of their input. | ||
|
||
function kill!(map::DeadMap, tomb::Int) | ||
i = Base.Sort.searchsortedfirst(map.t, tomb) | ||
# HERE: wait.. can the same data struct be used for u → w conversions? | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters