-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinear.go
More file actions
37 lines (29 loc) · 713 Bytes
/
linear.go
File metadata and controls
37 lines (29 loc) · 713 Bytes
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
package disgo
type LinearIndex struct {
entries map[PHash]bool
}
func NewLinearIndex() *LinearIndex {
li := new(LinearIndex)
li.entries = make(map[PHash]bool)
return li
}
func (li *LinearIndex) Insert(phash PHash) error {
li.entries[phash] = true
return nil
}
func (li *LinearIndex) Search(phash PHash, maxDistance int) ([]PHash, error) {
var results []PHash
// look for existing entry within maxDistance of the hash
for p := range li.entries {
if p.Distance(phash) <= maxDistance {
results = append(results, p)
}
}
return results, nil
}
func (li *LinearIndex) MarshalBinary() ([]byte, error) {
return nil, nil
}
func (li *LinearIndex) UnmarshalBinary(buf []byte) error {
return nil
}