Help us shape the future of Go! Take the 2026 Go Developer Survey

sorted

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 9 Imported by: 1

README

Sorted integer slices for small payloads

This sub-package contains a set of sorted sclices for minimising the payload. This can be useful in certain situations where you can sort a slice and send it to through the wire in the sorted format. This is essentially a trade-off between CPU and network bandwith.

Usage

This is a drop-in type, so simply use one of the types available in the package (Bools, Int32s, Uint64s ...) and Marshal or Unmarshal using the binary package.

// Marshal some numbers
v := sorted.Int32s{4, 5, 6, 1, 2, 3}
encoded, err := binary.Marshal(&v)

// Unmarshal the numbers
var o sorted.Int32s
err = binary.Unmarshal(encoded, &o)

Documentation

Overview

Copyright (c) Roman Atachiants and contributors. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IntsCodecAs added in v1.0.1

func IntsCodecAs(sliceType reflect.Type, sizeOfInt int) binary.Codec

func UintsCodecAs added in v1.0.1

func UintsCodecAs(sliceType reflect.Type, sizeOfInt int) binary.Codec

Types

type Int16s

type Int16s []int16

func (*Int16s) GetBinaryCodec

func (s *Int16s) GetBinaryCodec() binary.Codec

func (Int16s) Len

func (s Int16s) Len() int

func (Int16s) Less

func (s Int16s) Less(i, j int) bool

func (Int16s) Swap

func (s Int16s) Swap(i, j int)

type Int32s

type Int32s []int32

func (*Int32s) GetBinaryCodec

func (s *Int32s) GetBinaryCodec() binary.Codec

func (Int32s) Len

func (s Int32s) Len() int

func (Int32s) Less

func (s Int32s) Less(i, j int) bool

func (Int32s) Swap

func (s Int32s) Swap(i, j int)

type Int64s

type Int64s []int64

func (*Int64s) GetBinaryCodec

func (s *Int64s) GetBinaryCodec() binary.Codec

func (Int64s) Len

func (s Int64s) Len() int

func (Int64s) Less

func (s Int64s) Less(i, j int) bool

func (Int64s) Swap

func (s Int64s) Swap(i, j int)

type TimeCounters added in v1.0.18

type TimeCounters struct {
	Time []uint64 // Sorted timestamps compressed using delta-encoding
	Data []uint64 // Corresponding uint64 values
}

func (*TimeCounters) Append added in v1.0.18

func (ts *TimeCounters) Append(time, value uint64)

func (*TimeCounters) GetBinaryCodec added in v1.0.18

func (ts *TimeCounters) GetBinaryCodec() binary.Codec

func (*TimeCounters) Len added in v1.0.18

func (ts *TimeCounters) Len() int

func (*TimeCounters) Less added in v1.0.18

func (ts *TimeCounters) Less(i, j int) bool

func (*TimeCounters) Swap added in v1.0.18

func (ts *TimeCounters) Swap(i, j int)

type TimeSeries added in v1.0.13

type TimeSeries struct {
	Time []uint64  // Sorted timestamps compressed using delta-encoding
	Data []float64 // Corresponding float-64 values
}

func (*TimeSeries) Append added in v1.0.13

func (ts *TimeSeries) Append(time uint64, value float64)

func (*TimeSeries) GetBinaryCodec added in v1.0.13

func (ts *TimeSeries) GetBinaryCodec() binary.Codec

func (*TimeSeries) Len added in v1.0.13

func (ts *TimeSeries) Len() int

func (*TimeSeries) Less added in v1.0.13

func (ts *TimeSeries) Less(i, j int) bool

func (*TimeSeries) Swap added in v1.0.13

func (ts *TimeSeries) Swap(i, j int)

type Timestamps added in v1.0.13

type Timestamps []uint64

func (*Timestamps) GetBinaryCodec added in v1.0.13

func (ts *Timestamps) GetBinaryCodec() binary.Codec

type Uint16s

type Uint16s []uint16

func (*Uint16s) GetBinaryCodec

func (s *Uint16s) GetBinaryCodec() binary.Codec

func (Uint16s) Len

func (s Uint16s) Len() int

func (Uint16s) Less

func (s Uint16s) Less(i, j int) bool

func (Uint16s) Swap

func (s Uint16s) Swap(i, j int)

type Uint32s

type Uint32s []uint32

func (*Uint32s) GetBinaryCodec

func (s *Uint32s) GetBinaryCodec() binary.Codec

func (Uint32s) Len

func (s Uint32s) Len() int

func (Uint32s) Less

func (s Uint32s) Less(i, j int) bool

func (Uint32s) Swap

func (s Uint32s) Swap(i, j int)

type Uint64s

type Uint64s []uint64

func (*Uint64s) GetBinaryCodec

func (s *Uint64s) GetBinaryCodec() binary.Codec

func (Uint64s) Len

func (s Uint64s) Len() int

func (Uint64s) Less

func (s Uint64s) Less(i, j int) bool

func (Uint64s) Swap

func (s Uint64s) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL