-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.jl
More file actions
52 lines (40 loc) · 1.01 KB
/
index.jl
File metadata and controls
52 lines (40 loc) · 1.01 KB
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
# Copyright 2025, Jimmy Envall and contributors
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
import Base.hash
Letter = Int
struct Upper
letter::Letter
end
struct Lower
letter::Letter
end
LowerOrUpperIndex = Union{Lower,Upper}
IndexList = Vector{LowerOrUpperIndex}
function flip(index::Lower)
return Upper(index.letter)
end
function flip(index::Upper)
return Lower(index.letter)
end
function flip_to(index::Lower, letter::Letter)
return Upper(letter)
end
function flip_to(index::Upper, letter::Letter)
return Lower(letter)
end
function same_to(old::Lower, letter::Letter)
return Lower(letter)
end
function same_to(old::Upper, letter::Letter)
return Upper(letter)
end
function hash(arg::LowerOrUpperIndex, h::UInt)
val::UInt = 0
if typeof(arg) == Lower
val |= 1
end
val |= arg.letter << 1
hash(val, h)
end