circular

package
v0.0.0-...-d966d87 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package circular provides sliding-window data structures which are frequently useful when iterating through sorted BAM/PAM/BED files.

Index

Constants

View Source
const BitsPerWord = simd.BitsPerWord

BitsPerWord is the number of bits per machine word. (Don't want to import base/simd or base/bitset in files where we only need this constant.)

View Source
const FirstPosEmpty = bi.PosTypeMax

FirstPosEmpty is an empty-bitmap sentinel value. It must be larger than any real coordinate.

Variables

This section is empty.

Functions

func NextExp2

func NextExp2(x int) int

NextExp2 returns the next power of 2 strictly greater than x. (Useful when setting circular buffer size.)

Types

type Bitmap

type Bitmap struct {
	// contains filtered or unexported fields
}

Bitmap is a 2-dimensional bitmap, with circular major dimension. Variable and type names currently make the assumption that the major dimension corresponds to position; this can be abstracted out.

func NewBitmap

func NewBitmap(nCirc, rowWidth bi.PosType) (b Bitmap)

NewBitmap creates an empty Bitmap.

func (*Bitmap) CheckPanic

func (b *Bitmap) CheckPanic(tag string)

CheckPanic verifies the following invariants for a Bitmap, panicking on failure:

  • If either firstPos or lastPos is set to the "empty" value (FirstPosEmpty and -1, respectively), the other is as well.
  • If the bitmap isn't empty:
  • firstPos is in [lastPos, lastPos + nCirc).
  • wordPops[firstPos & (nCirc - 1)] and wordPops[lastPos & (nCirc - 1)] are nonzero.
  • For each i in [0, nCirc), wordPops[i] = # of nonzero words in Row(i).

func (*Bitmap) Clear

func (b *Bitmap) Clear(pos, circPos bi.PosType, colIdx uint32)

Clear clears a single bit of the bitmap. (Nothing bad happens if the bit was already clear.)

func (*Bitmap) FirstPos

func (b *Bitmap) FirstPos() bi.PosType

FirstPos returns the position of the first table entry, or FirstPosEmpty when the table is empty.

func (*Bitmap) NCirc

func (b *Bitmap) NCirc() bi.PosType

NCirc returns the major dimension size.

func (*Bitmap) NewRowScanner

func (b *Bitmap) NewRowScanner() (bitset.NonzeroWordScanner, int)

NewRowScanner returns a bitset.NonzeroWordScanner for the first nonempty table row, along with the position of the first set bit in the row. It is assumed that the row will be fully scanned before any other changes are made to the table.

func (*Bitmap) Row

func (b *Bitmap) Row(circPos bi.PosType) []uintptr

Row returns a []uintptr corresponding to a single row of the bitmap.

func (*Bitmap) Set

func (b *Bitmap) Set(pos, circPos bi.PosType, colIdx uint32)

Set sets a single bit of the bitmap. (Nothing bad happens if the bit was already set.)

Jump to

Keyboard shortcuts

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