Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions aggregation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package roaring

import (
"fmt"
"sort"
"slices"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -266,16 +266,6 @@ func TestHeapAggregations(t *testing.T) {
testAggregations(t, nil, HeapOr, HeapXor)
}

type uints []uint32

func (u uints) Len() int { return len(u) }

func (u uints) Less(i, j int) bool { return u[i] < u[j] }

func (u uints) Swap(i, j int) {
u[i], u[j] = u[j], u[i]
}

func TestIssue330(t *testing.T) {
var values = [][]uint32{
{1448147, 1331557, 1166809, 1404655, 1404657, 1448993, 1448994, 1555026, 1568981, 1166795, 1578735, 1456755, 1581128, 1166754, 1357064, 1166799, 1581142, 1166774, 1549034, 1090425, 1061936, 1581118, 1568668, 1456470, 1396063, 1597976, 1458021, 1344102, 1428259, 1166742, 1332378, 1456750, 1313881, 1371860, 1166770, 1513470, 1456761, 1520695, 1322567, 1456765, 1457788, 1166816, 1432713, 1581004, 1451025, 1166729, 1587500, 1581022, 1166707, 1489623, 1581108, 1547596, 1166727, 1345858, 1166741, 1473887, 1581152, 1581114, 1259737, 1434713, 1456740, 1492705, 1316224, 1448997, 1481940, 1456767, 1467183, 1576718, 1458286, 1475626, 1166785, 1428366, 1303084, 1061926, 1388553, 1453950, 1400529, 1581133, 1166713, 1581166, 1279364, 1322319, 1581027, 1166708, 1442325, 1510314, 1166761, 1404658, 1062733, 1166764, 1431819, 1568982, 1322271, 1427065, 1374050, 1166721, 1166714, 1321056, 1303185, 1329366, 1531398, 1071494, 1476413, 1373526, 1166793, 1404659, 1525886, 1166735, 1593361, 1496990, 1166748, 1366912, 1541272, 1166697, 1432913, 1559279, 1456736, 1315451, 1365178, 1068808, 1166768, 1581107, 1345349, 1166792, 1316413, 1449633, 1456758, 1567180, 1448998, 1423954, 1458607, 1480406, 1493217, 1469065, 1581164, 1581024, 1486803, 1550949, 1166803, 1166783, 1072253, 1499822, 1166724, 1559280, 1166732, 1488319, 1166796, 1062666, 1581165, 1507483, 1544041, 1483167, 1315400, 1166762, 1404660, 1581156, 1166786, 1499824, 1340819, 1166775, 1166710, 1473917, 1525946, 1166722, 1457787, 1166752, 1581158, 1500566, 1166736, 1581005, 1525788, 1166700, 1166720, 1341004, 1356523, 1259716, 1166815, 1166734, 1456734, 1393359, 1315351, 1166808, 1589134, 1166749, 1405717, 1386258, 1166733, 1166738, 1316508, 1510168, 1434714, 1341261, 1499823, 1166728, 1089511, 1166790, 1564869, 1316551, 1356413, 1401448, 1166703, 1456762, 1473571, 1405729, 1340780, 1263511, 1464349, 1166810, 1314421, 1519020, 1581006, 1514759, 1468171, 1320091, 1522288, 1456753, 1568393, 1581110, 1530461, 1456744, 1166750, 1518612, 1448325, 1314799, 1166696, 1166813, 1316622, 1489636, 1456741, 1166699, 1529489, 1481939, 1347707, 1448995, 1320330, 1466667, 1166739, 1166787, 1581009, 1323304, 1428380, 1456752, 1450469, 1496415, 1438461, 1450731, 1529496, 1166731, 1581141, 1581103, 1166706, 1064607, 1587650, 1474681, 1064608, 1166756, 1581015, 1573170, 1166801, 1581130, 1549033, 1166694, 1166800, 1593359, 1581155, 1540878, 1599952, 1538583, 1060736, 1166771, 1166711, 1166791, 1475206, 1166755, 1166798, 1455255, 1456751, 1464345, 1370294, 1401160, 1530295, 1573169, 1166804, 1061935, 1090681, 1349316, 1447675, 1449634, 1558271, 1581113, 1587248, 1540108, 1460873, 1562278, 1166788, 1530457, 1493594, 1456754, 1166753, 1320442, 1581153, 1166758, 1166737, 1322566, 1588195, 1166746, 1166777, 1492640, 1322682, 1166698, 1528367, 1445599, 1581026, 1166751, 1445781, 1319119, 1354380, 1581143, 1460447, 1166797, 1500720, 1369579, 1166806, 1581147, 1464393, 1492632, 1166780, 1448996, 1166712, 1593362, 1581151, 1166807, 1478408, 1322672, 1581137, 1581002, 1456764, 1405048, 1166766, 1063491, 1166811, 1296758, 1384972, 1314177, 1166730, 1066109, 1514764, 1567450, 1581119, 1573634, 1415662, 1563521, 1059518, 1456738, 1581157, 1550678, 1166726, 1166719, 1581013, 1495998, 1371312, 1584782, 1456471, 1166778, 1458759, 1060733, 1166784, 1581028, 1166781, 1583260, 1522601, 1491470, 1166717, 1319114, 1541228, 1456756, 1448992, 1166744, 1549031, 1570164, 1489634, 1370005, 1475624, 1514141, 1475625, 1525883, 1166817, 1166759, 1488332, 1313675, 1259957, 1581011, 1166725, 1483313, 1417102, 1166740, 1260680, 1166779, 1581134, 1315627, 1430811, 1525947, 1166763, 1435903, 1389401, 1351767, 1343593, 1537920, 1480377, 1520699, 1319223, 1581148, 1589060, 1060735, 1468871, 1087817, 1259068, 1581146, 1456759, 1404656, 1166776, 1166695, 1324844, 1589473, 1374167, 1166769, 1166789, 1456871, 1477673, 1166805, 1581106, 1379727, 1166723, 1166767, 1166745, 1313278, 1581124, 1451652, 1405710, 1408256, 1360274, 1325001, 1581136, 1166718, 1072246, 1410198, 1456746, 1557149, 1166760, 1308054, 1581159, 1581131, 1467536, 1166757, 1434322, 1541831, 1418436, 1574603, 1437326, 1166814, 1584856, 1388750, 1166743, 1372695, 1593360, 1166765, 1166794, 1474005, 1166782, 1456748, 1539639, 1056239, 1166802, 1166747, 1210989},
Expand All @@ -290,7 +280,7 @@ func TestIssue330(t *testing.T) {
bitmap.RunOptimize()
bitmaps = append(bitmaps, bitmap)
arrayResult := bitmap.ToArray()
sort.Sort(uints(v))
slices.Sort(v)
assert.Equal(t, arrayResult, v)
}
assert.Equal(t, FastAnd(bitmaps[0], bitmaps[1]).GetCardinality(), uint64(0))
Expand Down
7 changes: 3 additions & 4 deletions roaring64/bsi64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package roaring64

import (
"bytes"
"cmp"
"encoding/binary"
"fmt"
"io"
"math/big"
"math/rand"
"os"
"sort"
"slices"
"testing"
"time"

Expand Down Expand Up @@ -712,9 +713,7 @@ func testBsiRoundTrip(t *testing.T, pairs []bsiColValPair) {
it := bsi.GetExistenceBitmap().Iterator()
// The column ordering needs to match the one given by the iterator. This reorders the caller's
// slice.
sort.Slice(pairs, func(i, j int) bool {
return pairs[i].col < pairs[j].col
})
slices.SortFunc(pairs, func(a, b bsiColValPair) int { return cmp.Compare(a.col, b.col) })
for _, pair := range pairs {
if !it.HasNext() {
t.Fatalf("expected more columns: %v", pair.col)
Expand Down
16 changes: 4 additions & 12 deletions roaring64/fastaggregation64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package roaring64
// to run just these tests: go test -run TestFastAggregations*

import (
"github.com/stretchr/testify/assert"
"sort"
"slices"
"testing"

"github.com/stretchr/testify/assert"
)

func TestFastAggregationsAdvanced_run(t *testing.T) {
Expand Down Expand Up @@ -39,15 +40,6 @@ func TestFastAggregationsAdvanced_run(t *testing.T) {
assert.True(t, FastAnd(rb1, rb2, rb3).Equals(bigand))
}

type uints []uint64

func (u uints) Len() int { return len(u) }

func (u uints) Less(i, j int) bool { return u[i] < u[j] }

func (u uints) Swap(i, j int) {
u[i], u[j] = u[j], u[i]
}
func TestIssue330_64bits(t *testing.T) {
var values = [][]uint64{
{1448147, 1331557, 1166809, 1404655, 1404657, 1448993, 1448994, 1555026, 1568981, 1166795, 1578735, 1456755, 1581128, 1166754, 1357064, 1166799, 1581142, 1166774, 1549034, 1090425, 1061936, 1581118, 1568668, 1456470, 1396063, 1597976, 1458021, 1344102, 1428259, 1166742, 1332378, 1456750, 1313881, 1371860, 1166770, 1513470, 1456761, 1520695, 1322567, 1456765, 1457788, 1166816, 1432713, 1581004, 1451025, 1166729, 1587500, 1581022, 1166707, 1489623, 1581108, 1547596, 1166727, 1345858, 1166741, 1473887, 1581152, 1581114, 1259737, 1434713, 1456740, 1492705, 1316224, 1448997, 1481940, 1456767, 1467183, 1576718, 1458286, 1475626, 1166785, 1428366, 1303084, 1061926, 1388553, 1453950, 1400529, 1581133, 1166713, 1581166, 1279364, 1322319, 1581027, 1166708, 1442325, 1510314, 1166761, 1404658, 1062733, 1166764, 1431819, 1568982, 1322271, 1427065, 1374050, 1166721, 1166714, 1321056, 1303185, 1329366, 1531398, 1071494, 1476413, 1373526, 1166793, 1404659, 1525886, 1166735, 1593361, 1496990, 1166748, 1366912, 1541272, 1166697, 1432913, 1559279, 1456736, 1315451, 1365178, 1068808, 1166768, 1581107, 1345349, 1166792, 1316413, 1449633, 1456758, 1567180, 1448998, 1423954, 1458607, 1480406, 1493217, 1469065, 1581164, 1581024, 1486803, 1550949, 1166803, 1166783, 1072253, 1499822, 1166724, 1559280, 1166732, 1488319, 1166796, 1062666, 1581165, 1507483, 1544041, 1483167, 1315400, 1166762, 1404660, 1581156, 1166786, 1499824, 1340819, 1166775, 1166710, 1473917, 1525946, 1166722, 1457787, 1166752, 1581158, 1500566, 1166736, 1581005, 1525788, 1166700, 1166720, 1341004, 1356523, 1259716, 1166815, 1166734, 1456734, 1393359, 1315351, 1166808, 1589134, 1166749, 1405717, 1386258, 1166733, 1166738, 1316508, 1510168, 1434714, 1341261, 1499823, 1166728, 1089511, 1166790, 1564869, 1316551, 1356413, 1401448, 1166703, 1456762, 1473571, 1405729, 1340780, 1263511, 1464349, 1166810, 1314421, 1519020, 1581006, 1514759, 1468171, 1320091, 1522288, 1456753, 1568393, 1581110, 1530461, 1456744, 1166750, 1518612, 1448325, 1314799, 1166696, 1166813, 1316622, 1489636, 1456741, 1166699, 1529489, 1481939, 1347707, 1448995, 1320330, 1466667, 1166739, 1166787, 1581009, 1323304, 1428380, 1456752, 1450469, 1496415, 1438461, 1450731, 1529496, 1166731, 1581141, 1581103, 1166706, 1064607, 1587650, 1474681, 1064608, 1166756, 1581015, 1573170, 1166801, 1581130, 1549033, 1166694, 1166800, 1593359, 1581155, 1540878, 1599952, 1538583, 1060736, 1166771, 1166711, 1166791, 1475206, 1166755, 1166798, 1455255, 1456751, 1464345, 1370294, 1401160, 1530295, 1573169, 1166804, 1061935, 1090681, 1349316, 1447675, 1449634, 1558271, 1581113, 1587248, 1540108, 1460873, 1562278, 1166788, 1530457, 1493594, 1456754, 1166753, 1320442, 1581153, 1166758, 1166737, 1322566, 1588195, 1166746, 1166777, 1492640, 1322682, 1166698, 1528367, 1445599, 1581026, 1166751, 1445781, 1319119, 1354380, 1581143, 1460447, 1166797, 1500720, 1369579, 1166806, 1581147, 1464393, 1492632, 1166780, 1448996, 1166712, 1593362, 1581151, 1166807, 1478408, 1322672, 1581137, 1581002, 1456764, 1405048, 1166766, 1063491, 1166811, 1296758, 1384972, 1314177, 1166730, 1066109, 1514764, 1567450, 1581119, 1573634, 1415662, 1563521, 1059518, 1456738, 1581157, 1550678, 1166726, 1166719, 1581013, 1495998, 1371312, 1584782, 1456471, 1166778, 1458759, 1060733, 1166784, 1581028, 1166781, 1583260, 1522601, 1491470, 1166717, 1319114, 1541228, 1456756, 1448992, 1166744, 1549031, 1570164, 1489634, 1370005, 1475624, 1514141, 1475625, 1525883, 1166817, 1166759, 1488332, 1313675, 1259957, 1581011, 1166725, 1483313, 1417102, 1166740, 1260680, 1166779, 1581134, 1315627, 1430811, 1525947, 1166763, 1435903, 1389401, 1351767, 1343593, 1537920, 1480377, 1520699, 1319223, 1581148, 1589060, 1060735, 1468871, 1087817, 1259068, 1581146, 1456759, 1404656, 1166776, 1166695, 1324844, 1589473, 1374167, 1166769, 1166789, 1456871, 1477673, 1166805, 1581106, 1379727, 1166723, 1166767, 1166745, 1313278, 1581124, 1451652, 1405710, 1408256, 1360274, 1325001, 1581136, 1166718, 1072246, 1410198, 1456746, 1557149, 1166760, 1308054, 1581159, 1581131, 1467536, 1166757, 1434322, 1541831, 1418436, 1574603, 1437326, 1166814, 1584856, 1388750, 1166743, 1372695, 1593360, 1166765, 1166794, 1474005, 1166782, 1456748, 1539639, 1056239, 1166802, 1166747, 1210989},
Expand All @@ -61,7 +53,7 @@ func TestIssue330_64bits(t *testing.T) {
bitmap := BitmapOf(v...)
bitmap.RunOptimize()
bitmaps = append(bitmaps, bitmap)
sort.Sort(uints(v))
slices.Sort(v)
arrayResult := bitmap.ToArray()
assert.Equal(t, arrayResult, v)
}
Expand Down
16 changes: 2 additions & 14 deletions runcontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import (
"errors"
"fmt"
"sort"
"slices"
)

// runContainer16 does run-length encoding of sets of
Expand Down Expand Up @@ -113,18 +113,6 @@ func (rc *runContainer16) String() string {
return `runContainer16{` + is + `}`
}

// uint16Slice is a sort.Sort convenience method
type uint16Slice []uint16

// Len returns the length of p.
func (p uint16Slice) Len() int { return len(p) }

// Less returns p[i] < p[j]
func (p uint16Slice) Less(i, j int) bool { return p[i] < p[j] }

// Swap swaps elements i and j.
func (p uint16Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }

// addHelper helps build a runContainer16.
type addHelper16 struct {
runstart uint16
Expand Down Expand Up @@ -183,7 +171,7 @@ func newRunContainer16FromVals(alreadySorted bool, vals ...uint16) *runContainer
ah := addHelper16{rc: rc}

if !alreadySorted {
sort.Sort(uint16Slice(vals))
slices.Sort(vals)
}
n := len(vals)
var cur, prev uint16
Expand Down
8 changes: 4 additions & 4 deletions runcontainer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package roaring
import (
"fmt"
"math/rand"
"sort"
"slices"
"strings"
"testing"

Expand Down Expand Up @@ -495,7 +495,7 @@ func TestRleRandomIntersection16(t *testing.T) {
}

// print a; very likely it has dups
sort.Sort(uint16Slice(a))
slices.Sort(a)
stringA := ""
for i := range a {
stringA += fmt.Sprintf("%v, ", a[i])
Expand Down Expand Up @@ -591,7 +591,7 @@ func TestRleRandomUnion16(t *testing.T) {

union := arle.union(brle)
un := union.AsSlice()
sort.Sort(uint16Slice(un))
slices.Sort(un)

for kk, v := range un {
_ = kk
Expand Down Expand Up @@ -1261,7 +1261,7 @@ func TestRle16RemoveApi015(t *testing.T) {
}

func showArray16(a []uint16, name string) {
sort.Sort(uint16Slice(a))
slices.Sort(a)
stringA := ""
for i := range a {
stringA += fmt.Sprintf("%v, ", a[i])
Expand Down
4 changes: 2 additions & 2 deletions smat.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"os"
"path/filepath"
"runtime/debug"
"sort"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -132,7 +132,7 @@ func init() {
for actionId := range smatActionMap {
ids = append(ids, int(actionId))
}
sort.Ints(ids)
slices.Sort(ids)

pct := 100 / len(smatActionMap)
for _, actionId := range ids {
Expand Down
11 changes: 3 additions & 8 deletions util.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package roaring

import (
"cmp"
"math"
"math/rand"
"sort"
"slices"
)

const (
Expand Down Expand Up @@ -264,19 +265,13 @@ type ph struct {
rand int
}

type pha []ph

func (p pha) Len() int { return len(p) }
func (p pha) Less(i, j int) bool { return p[i].rand < p[j].rand }
func (p pha) Swap(i, j int) { p[i], p[j] = p[j], p[i] }

func getRandomPermutation(n int) []int {
r := make([]ph, n)
for i := 0; i < n; i++ {
r[i].orig = i
r[i].rand = rand.Intn(1 << 29)
}
sort.Sort(pha(r))
slices.SortFunc(r, func(a, b ph) int { return cmp.Compare(a.rand, b.rand) })
m := make([]int, n)
for i := range m {
m[i] = r[i].orig
Expand Down
Loading