mempager

package
v0.0.0-...-ceb2c1b Latest Latest
Warning

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

Go to latest
Published: May 18, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_PAGE_SIZE = 1024

Variables

This section is empty.

Functions

This section is empty.

Types

type Page

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

Page is an indexed representation of a chunk of memory

func (Page) Buffer

func (p Page) Buffer() *[]byte

Buffer returns a pointer to the internal byte buffer of the page

func (Page) Offset

func (p Page) Offset() int

Offset returns the byte offset of the page relvative to the other pages within the pager

type Pager

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

Pager is a tool used to reference chunks of memory (pages) Allows retrieval, allocation, and setting memory contents by an index

func NewPager

func NewPager(pageSize int) Pager

NewPager constructs a new pager with the specified pageSize Defaults the page size to 1024 bytes if passed a size of 0

func (Pager) Get

func (p Pager) Get(pageNum int) *Page

Get will return the page at the specified index

func (*Pager) GetOrAlloc

func (p *Pager) GetOrAlloc(pageNum int) (page *Page)

GetOrAlloc will return the page at the specified index, allocating it if not already allocated

func (Pager) IsEmpty

func (p Pager) IsEmpty() bool

IsEmpty will check if the memory page is empty (has zero pages)

func (Pager) Len

func (p Pager) Len() int

Len will return the size of the pager (number of pages)

func (Pager) PageSize

func (p Pager) PageSize() int

PageSize will return the page size of the pager

func (*Pager) Set

func (p *Pager) Set(pageNum int, data []byte)

Set will set the contents of the page at the specified index, with the provided data Allocates a new page if it doesn't already exist

Jump to

Keyboard shortcuts

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