-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathregommenditem.go
46 lines (39 loc) · 1001 Bytes
/
regommenditem.go
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
/*
* Simple recommendation engine
* Copyright (c) 2014, Christian Muehlhaeuser <muesli@gmail.com>
*
* For license see LICENSE.txt
*/
package regommend
import (
"sync"
_ "time"
)
// Structure of an item in the recommendation engine.
// Parameter data contains the user-set value in the engine.
type RegommendItem struct {
sync.RWMutex
// The item's key.
key interface{}
// All items for this key.
data map[interface{}]float64
}
// CreateRegommendItem returns a newly created RegommendItem.
// Parameter key is the item's key.
// Parameter data is the item's value.
func CreateRegommendItem(key interface{}, data map[interface{}]float64) RegommendItem {
return RegommendItem{
key: key,
data: data,
}
}
// Key returns the key of this item.
func (item *RegommendItem) Key() interface{} {
// immutable
return item.key
}
// Data returns the value of this item.
func (item *RegommendItem) Data() map[interface{}]float64 {
// immutable
return item.data
}