Skip to content

Commit

Permalink
選択アルゴリズムの変更
Browse files Browse the repository at this point in the history
  • Loading branch information
ledyba committed Dec 25, 2018
1 parent b6d0bc1 commit d0c3723
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions web/moment.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ func (srv *Server) serveMomentSearch(w http.ResponseWriter, r *http.Request, _ h
return
}
pi2 := math.Pi * 2.0
lst := make([][]*momentSummary, size)
lst := make([][]*momentSummary, int(math.Ceil(math.Sqrt(float64(size)))))
orig := srv.shelf.FindAllMoments()
if size > len(orig) {
size = len(orig)
}
for _, v := range rand.Perm(len(orig)) {
s := srv.makeSummary(orig[v])
i := int(math.Round(s.Angle*float64(size)/pi2)) % size
i := int(math.Round(s.Angle*float64(len(lst))/pi2)) % len(lst)
lst[i] = append(lst[i], s)
}
out := make([]*momentSummary, size)
Expand Down

0 comments on commit d0c3723

Please sign in to comment.