kaigouthro

keyed value types with pseudo-dict - Methods

Library "key_vals"
a set of primitive single-type key/value items, and pseudo-dictionaries
The dictionaries are single arrays of items, each item has a key and value.
The library is 100% methods. add, remove, get and set items by key.
It provides methods to get all the keys, values or items in the dict as arrays.
For those familiar with python, it's similar, but typified.. and the brackets are round.



example syntax.. using floats, the same functions exist for Int, Bool and String

new float_item
new (‘demo’, 1.0 )

set the key of a float_item
float_item.key (‘demo’)

get the key of a float_item
float_item.key ()

set the value of a float_item
float_item.val (1.5)

get the value of a float_item
float_item.val ()

get the number of items in a dict
float_dict.count ()

set an item to a dict by key ( add / update)
float_dict.set ( ‘demo’, 2.0 )

remove an item from a dict by key (changes index, but this is about keys, not ids)
float_dict.remove ( ‘demo’ )

get an item from a dict array
array<float_dict>.get (1 )

get an item from a dict by key
float_dict.get ( ‘demo’ )

get an item from a dict by id (remember, ids change if removed by key) mainlyy an internal function
float_dict.get ( 1)

return all keys as string
float_dict.get_keys()

return all values as float
float_dict.get_values()

return all items as float
float_dict.get_items()

create a new float dict in the multi dict and return the index of it
multi_dict.add_float_dict()

get the float dict at index 0 from the multi dict
multi_dict.get_float_dict( 0)

set an item in a float dict in a multi dict
multi_dict.set_float( ‘demo’, 2.0 )

get an item from a float dict in a multi dict
multi_dict.get_float( ‘demo’ )



float_item
  float_item
  Fields:
    key: (string)
    val: (float)
    next: (float_item)

float_dict
  float_dict
  Fields:
    content

int_item
  int_item
  Fields:
    key: (string)
    val: (int)
    next: (int_item)

int_dict
  int_dict
  Fields:
    content

string_item
  string_item
  Fields:
    key: (string)
    val: (string)
    next: (string_item)

string_dict
  string_dict
  Fields:
    content

bool_item
  bool_item
  Fields:
    key: (string)
    val: (bool)
    next: (bool_item)

bool_dict
  bool_dict
  Fields:
    content

multi_dict
  multi_dict
  Fields:
    f_dicts
    f_registry
    i_dicts
    i_registry
    s_dicts
    s_registry
    b_dicts
    b_registry








new(key, val)
  new
  Parameters:
    key: string
    val: float

new(key, val)
  Parameters:
    key
    val

new(key, val)
  Parameters:
    key
    val

new(key, val)
  Parameters:
    key
    val

key(this, key)
  key
  Parameters:
    this: float_item
    key: string

key(this)
  key
  Parameters:
    this: float_item

key(this, key)
  Parameters:
    this
    key

key(this)
  Parameters:
    this

key(this, key)
  Parameters:
    this
    key

key(this)
  Parameters:
    this

key(this, key)
  Parameters:
    this
    key

key(this)
  Parameters:
    this

val(this)
  val
  Parameters:
    this: float_item

val(this, val)
  val
  Parameters:
    this: float_item
    val: float

val(this)
  Parameters:
    this

val(this, val)
  Parameters:
    this
    val

val(this)
  Parameters:
    this

val(this, val)
  Parameters:
    this
    val

val(this)
  Parameters:
    this

val(this, val)
  Parameters:
    this
    val

count(dict)
  count
  Parameters:
    dict: float_dict

count(dict)
  Parameters:
    dict

count(dict)
  Parameters:
    dict

count(dict)
  Parameters:
    dict

get(dict, index)
  get
  Parameters:
    dict: float_dict
    index: int

get(dict, index)
  get
  Parameters:
    dict: float_dict
    index: int

get(d, key)
  Parameters:
    d
    key

get(dict, index)
  Parameters:
    dict
    index

get(dict, index)
  Parameters:
    dict
    index

get(d, key)
  Parameters:
    d
    key

get(dict, index)
  Parameters:
    dict
    index

get(dict, index)
  Parameters:
    dict
    index

get(d, key)
  Parameters:
    d
    key

get(dict, index)
  Parameters:
    dict
    index

get(dict, index)
  Parameters:
    dict
    index

get(d, key)
  Parameters:
    d
    key

set(d, key, val)
  set
  Parameters:
    d: float_dict
    key: string
    val: float

set(d, key, val)
  Parameters:
    d
    key
    val

set(d, key, val)
  Parameters:
    d
    key
    val

set(d, key, val)
  Parameters:
    d
    key
    val

get_keys(d)
  Parameters:
    d

get_keys(d)
  Parameters:
    d

get_keys(d)
  Parameters:
    d

get_keys(d)
  Parameters:
    d

get_values(d)
  Parameters:
    d

get_values(d)
  Parameters:
    d

get_values(d)
  Parameters:
    d

get_values(d)
  Parameters:
    d

get_items(d)
  Parameters:
    d

get_items(d)
  Parameters:
    d

get_items(d)
  Parameters:
    d

get_items(d)
  Parameters:
    d

remove(dict, key)
  Parameters:
    dict
    key

remove(dict, key)
  Parameters:
    dict
    key

remove(dict, key)
  Parameters:
    dict
    key

remove(dict, key)
  Parameters:
    dict
    key

create_multi_dict()

add_float_dict(this)
  Parameters:
    this

add_int_dict(this)
  Parameters:
    this

add_string_dict(this)
  Parameters:
    this

add_bool_dict(this)
  Parameters:
    this

get_float_dict(this, index)
  Parameters:
    this
    index

get_float_dict(this, key)
  Parameters:
    this
    key

get_int_dict(this, index)
  Parameters:
    this
    index

get_int_dict(this, key)
  Parameters:
    this
    key

get_string_dict(this, index)
  Parameters:
    this
    index

get_string_dict(this, key)
  Parameters:
    this
    key

get_bool_dict(this, index)
  Parameters:
    this
    index

get_bool_dict(this, key)
  Parameters:
    this
    key

set_float(this, key, val)
  Parameters:
    this
    key
    val

set_int(this, key, val)
  Parameters:
    this
    key
    val

set_string(this, key, val)
  Parameters:
    this
    key
    val

set_bool(this, key, val)
  Parameters:
    this
    key
    val
Libreria Pine

Nello spirito di condivisione promosso da TradingView, l'autore (al quale vanno i nostri ringraziamenti) ha deciso di pubblicare questo script in modalità open-source, così che chiunque possa comprenderlo e testarlo. Puoi utilizzare questa libreria in privato o all'interno di altre pubblicazioni open-source, ma il riutilizzo del codice è subordinato al rispetto del Regolamento.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.

Vuoi usare questa libreria?

Copia il testo ed incollalo nel tuo script.