many many things

This commit is contained in:
didier amyot committed 2015-06-22 08:14:55 -04:00
1 parent fb9084794c
commit af69e728a2
9 files changed
+253 -59

No files matched your search

+5 -4
View File
@@ -3,7 +3,6 @@ package doorman
import (
"encoding/json"
"errors"
"fmt"
"log"
"math"
"math/big"
@@ -17,8 +16,6 @@ import (
"gopkg.in/mgo.v2/bson"
)
var _ = fmt.Print
var ONE *big.Rat = big.NewRat(1, 1)
var rand *mathrand.Rand
@@ -43,7 +40,7 @@ type Doorman struct {
wg sync.WaitGroup // waitgroup for goroutine safety
}
func NewDoorman(id bson.ObjectId, Probabilities []*big.Rat) *Doorman {
func New(id bson.ObjectId, Probabilities []*big.Rat) *Doorman {
wab := &Doorman{}
wab.Id = id
wab.Probabilities = Probabilities
@@ -143,6 +140,10 @@ func (w *Doorman) GetCaseFromData(data ...[]byte) uint {
return w.GetCase(random)
}
func (w *Doorman) GetCaseFromString(data string) uint {
return w.GetCaseFromData([]byte(data))
}
func (w *Doorman) GetRandomCase() uint {
r := rand.Float64()
return w.GetCase(new(big.Rat).SetFloat64(r))