data_type

package
v0.0.0-...-0cc5829 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MPL-2.0 Imports: 4 Imported by: 3

Documentation

Overview

Package data_type defines the generic data types used in SDS.

Supported data types are:

  • Queue is the list where the new element is added to the end, but when an element is taken its taken from the top. Queue doesn't allow addition of any kind of element. All elements should have the same type.
  • Key_value different kinds of maps
  • serialize functions to serialize any structure to the bytes and vice versa.

Package data_type defines the generic data types used in SDS.

Supported data types are:

  • Queue is the list where the new element is added to the end, but when an element is taken its taken from the top. Queue doesn't allow addition of any kind of element. All elements should have the same type.
  • Key_value different kinds of maps
  • serialize functions to serialize any structure to the bytes and vice versa.

Index

Constants

View Source
const QueueCap uint = 10

Variables

This section is empty.

Functions

func AddJsonPrefix

func AddJsonPrefix(bytes []byte) string

func DecodeJsonPrefixed

func DecodeJsonPrefixed(str string) string

func Deserialize

func Deserialize(bytes []byte, body interface{}) error

Deserialize the given string to the map, slice or struct.

func IsJsonPrefixed

func IsJsonPrefixed(str string) bool

func IsNil

func IsNil(v interface{}) bool

func IsPointer

func IsPointer(body interface{}) bool

func Serialize

func Serialize(body interface{}) ([]byte, error)

Serialize wraps the JSON abi interface to the internal data type. It's blockchain agnostic.

Types

type Queue

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

func NewQueue

func NewQueue() *Queue

NewQueue returns the queue of the elements that could contain maximum QUEUE_LENGTH number of elements.

The queue has a function that returns the first element by taking it out from the list.

The added elements attached after the last element.

func (*Queue) Cap

func (q *Queue) Cap() uint

Cap returns the capacity of the queue

func (*Queue) First

func (q *Queue) First() interface{}

First returns the first element without removing it from the queue If there is no element, then returns nil

func (*Queue) IsEmpty

func (q *Queue) IsEmpty() bool

func (*Queue) IsFull

func (q *Queue) IsFull() bool

func (*Queue) Len

func (q *Queue) Len() uint

func (*Queue) Pop

func (q *Queue) Pop() interface{}

Pop takes the first element from the list and returns it. If there is no element in the list, then return nil

func (*Queue) Push

func (q *Queue) Push(item interface{})

Push the element into the queue. If the element type is not the same as the expected type, then It will silently drop it. Silently drop if the queue is full

func (*Queue) SetCap

func (q *Queue) SetCap(newCap uint) error

SetCap updates the queue size if it's possible. If the new cap is less that current queue size throws an error. Otherwise, queue will lose access to the items.

Directories

Path Synopsis
Package database keeps the utility functions that converts database type to internal golang type
Package database keeps the utility functions that converts database type to internal golang type
Package key_value defines the custom map and its additional functions.
Package key_value defines the custom map and its additional functions.

Jump to

Keyboard shortcuts

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