PINE LIBRARY

arrays

Updated
Library "arraymethods"
Supplementary array methods.

delete(arr, index)
  remove int object from array of integers at specific index
  Parameters:
    arr: int array
    index: index at which int object need to be removed
  Returns: void

delete(arr, index)
  remove float object from array of float at specific index
  Parameters:
    arr: float array
    index: index at which float object need to be removed
  Returns: float

delete(arr, index)
  remove bool object from array of bool at specific index
  Parameters:
    arr: bool array
    index: index at which bool object need to be removed
  Returns: bool

delete(arr, index)
  remove string object from array of string at specific index
  Parameters:
    arr: string array
    index: index at which string object need to be removed
  Returns: string

delete(arr, index)
  remove color object from array of color at specific index
  Parameters:
    arr: color array
    index: index at which color object need to be removed
  Returns: color

delete(arr, index)
  remove line object from array of lines at specific index and deletes the line
  Parameters:
    arr: line array
    index: index at which line object need to be removed and deleted
  Returns: void

delete(arr, index)
  remove label object from array of labels at specific index and deletes the label
  Parameters:
    arr: label array
    index: index at which label object need to be removed and deleted
  Returns: void

delete(arr, index)
  remove box object from array of boxes at specific index and deletes the box
  Parameters:
    arr: box array
    index: index at which box object need to be removed and deleted
  Returns: void

delete(arr, index)
  remove table object from array of tables at specific index and deletes the table
  Parameters:
    arr: table array
    index: index at which table object need to be removed and deleted
  Returns: void

delete(arr, index)
  remove linefill object from array of linefills at specific index and deletes the linefill
  Parameters:
    arr: linefill array
    index: index at which linefill object need to be removed and deleted
  Returns: void

popr(arr)
  remove last int object from array
  Parameters:
    arr: int array
  Returns: int

popr(arr)
  remove last float object from array
  Parameters:
    arr: float array
  Returns: float

popr(arr)
  remove last bool object from array
  Parameters:
    arr: bool array
  Returns: bool

popr(arr)
  remove last string object from array
  Parameters:
    arr: string array
  Returns: string

popr(arr)
  remove last color object from array
  Parameters:
    arr: color array
  Returns: color

popr(arr)
  remove and delete last line object from array
  Parameters:
    arr: line array
  Returns: void

popr(arr)
  remove and delete last label object from array
  Parameters:
    arr: label array
  Returns: void

popr(arr)
  remove and delete last box object from array
  Parameters:
    arr: box array
  Returns: void

popr(arr)
  remove and delete last table object from array
  Parameters:
    arr: table array
  Returns: void

popr(arr)
  remove and delete last linefill object from array
  Parameters:
    arr: linefill array
  Returns: void

shiftr(arr)
  remove first int object from array
  Parameters:
    arr: int array
  Returns: int

shiftr(arr)
  remove first float object from array
  Parameters:
    arr: float array
  Returns: float

shiftr(arr)
  remove first bool object from array
  Parameters:
    arr: bool array
  Returns: bool

shiftr(arr)
  remove first string object from array
  Parameters:
    arr: string array
  Returns: string

shiftr(arr)
  remove first color object from array
  Parameters:
    arr: color array
  Returns: color

shiftr(arr)
  remove and delete first line object from array
  Parameters:
    arr: line array
  Returns: void

shiftr(arr)
  remove and delete first label object from array
  Parameters:
    arr: label array
  Returns: void

shiftr(arr)
  remove and delete first box object from array
  Parameters:
    arr: box array
  Returns: void

shiftr(arr)
  remove and delete first table object from array
  Parameters:
    arr: table array
  Returns: void

shiftr(arr)
  remove and delete first linefill object from array
  Parameters:
    arr: linefill array
  Returns: void

push(arr, val, maxItems)
  add int to the end of an array with max items cap. Objects are removed from start to maintain max items cap
  Parameters:
    arr: int array
    val: int object to be pushed
    maxItems: max number of items array can hold
  Returns: int[]

push(arr, val, maxItems)
  add float to the end of an array with max items cap. Objects are removed from start to maintain max items cap
  Parameters:
    arr: float array
    val: float object to be pushed
    maxItems: max number of items array can hold
  Returns: float[]

push(arr, val, maxItems)
  add bool to the end of an array with max items cap. Objects are removed from start to maintain max items cap
  Parameters:
    arr: bool array
    val: bool object to be pushed
    maxItems: max number of items array can hold
  Returns: bool[]

push(arr, val, maxItems)
  add string to the end of an array with max items cap. Objects are removed from start to maintain max items cap
  Parameters:
    arr: string array
    val: string object to be pushed
    maxItems: max number of items array can hold
  Returns: string[]

push(arr, val, maxItems)
  add color to the end of an array with max items cap. Objects are removed from start to maintain max items cap
  Parameters:
    arr: color array
    val: color object to be pushed
    maxItems: max number of items array can hold
  Returns: color[]

push(arr, val, maxItems)
  add line to the end of an array with max items cap. Objects are removed and deleted from start to maintain max items cap
  Parameters:
    arr: line array
    val: line object to be pushed
    maxItems: max number of items array can hold
  Returns: line[]

push(arr, val, maxItems)
  add label to the end of an array with max items cap. Objects are removed and deleted from start to maintain max items cap
  Parameters:
    arr: label array
    val: label object to be pushed
    maxItems: max number of items array can hold
  Returns: label[]

push(arr, val, maxItems)
  add box to the end of an array with max items cap. Objects are removed and deleted from start to maintain max items cap
  Parameters:
    arr: box array
    val: box object to be pushed
    maxItems: max number of items array can hold
  Returns: box[]

push(arr, val, maxItems)
  add table to the end of an array with max items cap. Objects are removed and deleted from start to maintain max items cap
  Parameters:
    arr: table array
    val: table object to be pushed
    maxItems: max number of items array can hold
  Returns: table[]

push(arr, val, maxItems)
  add linefill to the end of an array with max items cap. Objects are removed and deleted from start to maintain max items cap
  Parameters:
    arr: linefill array
    val: linefill object to be pushed
    maxItems: max number of items array can hold
  Returns: linefill[]

unshift(arr, val, maxItems)
  add int to the beginning of an array with max items cap. Objects are removed from end to maintain max items cap
  Parameters:
    arr: int array
    val: int object to be unshift
    maxItems: max number of items array can hold
  Returns: int[]

unshift(arr, val, maxItems)
  add float to the beginning of an array with max items cap. Objects are removed from end to maintain max items cap
  Parameters:
    arr: float array
    val: float object to be unshift
    maxItems: max number of items array can hold
  Returns: float[]

unshift(arr, val, maxItems)
  add bool to the beginning of an array with max items cap. Objects are removed from end to maintain max items cap
  Parameters:
    arr: bool array
    val: bool object to be unshift
    maxItems: max number of items array can hold
  Returns: bool[]

unshift(arr, val, maxItems)
  add string to the beginning of an array with max items cap. Objects are removed from end to maintain max items cap
  Parameters:
    arr: string array
    val: string object to be unshift
    maxItems: max number of items array can hold
  Returns: string[]

unshift(arr, val, maxItems)
  add color to the beginning of an array with max items cap. Objects are removed from end to maintain max items cap
  Parameters:
    arr: color array
    val: color object to be unshift
    maxItems: max number of items array can hold
  Returns: color[]

unshift(arr, val, maxItems)
  add line to the beginning of an array with max items cap. Objects are removed and deleted from end to maintain max items cap
  Parameters:
    arr: line array
    val: line object to be unshift
    maxItems: max number of items array can hold
  Returns: line[]

unshift(arr, val, maxItems)
  add label to the beginning of an array with max items cap. Objects are removed and deleted from end to maintain max items cap
  Parameters:
    arr: label array
    val: label object to be unshift
    maxItems: max number of items array can hold
  Returns: label[]

unshift(arr, val, maxItems)
  add box to the beginning of an array with max items cap. Objects are removed and deleted from end to maintain max items cap
  Parameters:
    arr: box array
    val: box object to be unshift
    maxItems: max number of items array can hold
  Returns: box[]

unshift(arr, val, maxItems)
  add table to the beginning of an array with max items cap. Objects are removed and deleted from end to maintain max items cap
  Parameters:
    arr: table array
    val: table object to be unshift
    maxItems: max number of items array can hold
  Returns: table[]

unshift(arr, val, maxItems)
  add linefill to the beginning of an array with max items cap. Objects are removed and deleted from end to maintain max items cap
  Parameters:
    arr: linefill array
    val: linefill object to be unshift
    maxItems: max number of items array can hold
  Returns: linefill[]

flush(arr)
  remove all int objects in an array
  Parameters:
    arr: int array
  Returns: int[]

flush(arr)
  remove all float objects in an array
  Parameters:
    arr: float array
  Returns: float[]

flush(arr)
  remove all bool objects in an array
  Parameters:
    arr: bool array
  Returns: bool[]

flush(arr)
  remove all string objects in an array
  Parameters:
    arr: string array
  Returns: string[]

flush(arr)
  remove all color objects in an array
  Parameters:
    arr: color array
  Returns: color[]

flush(arr)
  remove and delete all line objects in an array
  Parameters:
    arr: line array
  Returns: line[]

flush(arr)
  remove and delete all label objects in an array
  Parameters:
    arr: label array
  Returns: label[]

flush(arr)
  remove and delete all box objects in an array
  Parameters:
    arr: box array
  Returns: box[]

flush(arr)
  remove and delete all table objects in an array
  Parameters:
    arr: table array
  Returns: table[]

flush(arr)
  remove and delete all linefill objects in an array
  Parameters:
    arr: linefill array
  Returns: linefill[]
Release Notes
v2

Added:
method isEmpty(arr)
  checks if a table array is either null or empty
  Namespace types: array<table>
  Parameters:
    arr (array<table>): table array
  Returns: bool

method isNotEmpty(arr)
  checks if a table array is not null and has at least one item
  Namespace types: array<table>
  Parameters:
    arr (array<table>): table array
  Returns: bool
arrayshewhomustnotbenamedlibrarytrendoscope

Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House rules.

Disclaimer