Permuted sets indexes to a permuted order -- if indexes already exist then existing list of indexes is permuted, otherwise a new set of permuted indexes are generated
()
| 88 | // then existing list of indexes is permuted, otherwise a new set of |
| 89 | // permuted indexes are generated |
| 90 | func (ix *IndexView) Permuted() { |
| 91 | if ix.Table == nil || ix.Table.Rows <= 0 { |
| 92 | ix.Indexes = nil |
| 93 | return |
| 94 | } |
| 95 | if len(ix.Indexes) == 0 { |
| 96 | ix.Indexes = rand.Perm(ix.Table.Rows) |
| 97 | } else { |
| 98 | rand.Shuffle(len(ix.Indexes), func(i, j int) { |
| 99 | ix.Indexes[i], ix.Indexes[j] = ix.Indexes[j], ix.Indexes[i] |
| 100 | }) |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | // AddIndex adds a new index to the list |
| 105 | func (ix *IndexView) AddIndex(idx int) { |