gfilespace

package
v0.0.0-...-819f294 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

文件空间管理

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

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

文件空闲块

func (*Block) Index

func (block *Block) Index() int

获得碎片偏移量

func (*Block) Less

func (block *Block) Less(item gbtree.Item) bool

用于B+树的接口具体实现定义

func (*Block) Size

func (block *Block) Size() int

获得碎片大小

type Space

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

文件空间管理结构体

func New

func New() *Space

创建一个空间管理器

func (*Space) AddBlock

func (space *Space) AddBlock(index int, size int)

添加空闲空间到管理器

func (*Space) Contains

func (space *Space) Contains(index int, size int) bool

给定的空间块*整块*是否包含在管理器中

func (*Space) Export

func (space *Space) Export() []byte

导出空间块数据

func (*Space) GetAllBlocks

func (space *Space) GetAllBlocks() []Block

获得所有的碎片空间,按照index升序排序

func (*Space) GetAllSizes

func (space *Space) GetAllSizes() []uint

获得所有的碎片空间大小列表,按照size升序排序

func (*Space) GetBlock

func (space *Space) GetBlock(size int) (int, int)

申请空间,返回文件地址及大小,返回成功后则在管理器中删除该空闲块

func (*Space) GetMaxBlock

func (space *Space) GetMaxBlock() *Block

获取索引最大的空间块

func (*Space) GetMaxSize

func (space *Space) GetMaxSize() int

获取当前空间管理器中最大的空闲块大小

func (*Space) GetMinBlock

func (space *Space) GetMinBlock() *Block

获取索引最小的空间块

func (*Space) Import

func (space *Space) Import(content []byte)

导入空间块数据

func (*Space) Len

func (space *Space) Len() int

获取空间块的数量

func (*Space) RemoveBlock

func (space *Space) RemoveBlock(index int)

删除指定索引位置的空间块

func (*Space) SumSize

func (space *Space) SumSize() int

计算总的空闲空间大小

Jump to

Keyboard shortcuts

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