ul

package
v0.0.60 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Err_DestinationIsNotInitialised = "destination is not initialised"
	Err_ItemsAreNotUnique           = "items are not unique"
	Err_EdgePosition                = "edge position"
	Err_Position                    = "position error"

	ErrF_UidIsNotFound       = "uid is not found: %v"
	ErrF_DuplicateUid        = "duplicate uid: %v"
	ErrF_UnsupportedDataType = "unsupported data type: %s"
)
View Source
const (
	IndexOnError      = cmb.Index(-1)
	ListItemSeparator = ","
	StringOnError     = ""
)

Variables

This section is empty.

Functions

This section is empty.

Types

type UidList

type UidList []cmb.Id

UidList is a list unique identifiers.

The main purpose of this list is to store a chronological order of all added identifiers. The order of items in the list is important and, thus, the list may not be sorted. New items are added to the end of the list, deleted items shift existing items. All operations on the list assume that the list is unique before the operation, thus, every operation must ensure that its results do not break the uniqueness of items in the list.

func New

func New() (ul *UidList)

func NewFromArray

func NewFromArray(uids []cmb.Id) (ul *UidList, err error)

func (*UidList) AddItem

func (ul *UidList) AddItem(uid cmb.Id, addToTop bool) (err error)

AddItem add a new identifier to the end of the list. If 'addToTop' is set to 'True', then the item is added to the beginning (top) of the list; otherwise – to the end (bottom) of the list.

func (*UidList) AsArray added in v0.0.54

func (ul *UidList) AsArray() (arr []cmb.Id)

AsArray returns the list as an array.

func (*UidList) CheckIntegrity

func (ul *UidList) CheckIntegrity() (err error)

CheckIntegrity verifies integrity of the list.

func (*UidList) HasItem added in v0.0.49

func (ul *UidList) HasItem(uid cmb.Id) bool

HasItem checks whether an item is contained in the list or not.

func (*UidList) LastElement added in v0.0.44

func (ul *UidList) LastElement() (lastElement *cmb.Id)

LastElement returns the last item of the list.

func (*UidList) MoveItemDown added in v0.0.38

func (ul *UidList) MoveItemDown(uid cmb.Id) (err error)

MoveItemDown moves an existing identifier one position downwards if possible.

func (*UidList) MoveItemUp added in v0.0.38

func (ul *UidList) MoveItemUp(uid cmb.Id) (err error)

MoveItemUp moves an existing identifier one position upwards if possible.

func (*UidList) OnPage

func (ul *UidList) OnPage(pageNumber cmb.Count, pageSize cmb.Count) (ulop *UidList)

OnPage returns paginated items.

func (*UidList) RaiseItem

func (ul *UidList) RaiseItem(uid cmb.Id) (isAlreadyRaised bool, err error)

RaiseItem moves an existing identifier to the top of the list.

func (*UidList) RemoveItem

func (ul *UidList) RemoveItem(uid cmb.Id) (err error)

RemoveItem deletes an identifier from the list shifting its items.

func (*UidList) RemoveItemAtPos added in v0.0.49

func (ul *UidList) RemoveItemAtPos(pos cmb.Index) (err error)

RemoveItemAtPos removes the item at position.

func (*UidList) Scan

func (ul *UidList) Scan(src any) (err error)

Scan method provides compatibility with SQL JSON data type.

func (*UidList) SearchForItem added in v0.0.49

func (ul *UidList) SearchForItem(uid cmb.Id) (idx cmb.Index, err error)

SearchForItem searches for an item in the list. If an item is found, its index is returned without error. If an item is not found, an error is returned.

func (*UidList) Size

func (ul *UidList) Size() (n cmb.Count)

Size returns list's size, i.e. it counts the items.

func (*UidList) Value

func (ul *UidList) Value() (dv driver.Value, err error)

Value method provides compatibility with SQL JSON data type.

func (*UidList) ValuesString

func (ul *UidList) ValuesString() (values string, err error)

ValuesString lists items as a simple plain text with a comma as separator.

Jump to

Keyboard shortcuts

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