ObjectType:index

From Lavish Software Wiki
Jump to: navigation, search

Description

Object Type Vitals
index
Defined By LavishScript
Inherits objectcontainer
Reduces To NULL
Variable Object Type index
Uses Sub-Types yes
C/C++ Type LSIndex *

An index is a dynamically-sized list of objects. In contrast to arrays, elements in an index are not created when the index is sized -- the elements do not exist until set.

The index position used by any operation must exist at the time of usage for the operation to be successful (see Resize). The index is not automatically resized for any operation except for Insert.

An Index cannot have multiple dimensions, but you can create an array of indexes.

Members

  • uint Next[#]: Retrieves the ID of the next valid element in the index, given an ID number
  • sub-type Get[#]: Retrieves the #th element in the index
  • uint Insert[...]: Inserts an element in the index. The parameters will be passed to the object initialization routine for the index sub-type, and an object will be created. The returned value is the ID of the new element. The index will be resized to fit the new object if necessary.
  • mutablestring Expand[begin #,length]: Retrieves the text representation of each existing object in the index as quoted parameters, separated by spaces. If no parameters are given to Expand, the entire index will be used. If only the begin # is used, the rest of the index, beginning with the element # specified, will be used. If the length is additionally given, that number of elements from the index will be used, beginning with the element # specified as the beginning.
  • mutablestring ExpandComma[begin #,length]: Retrieves the text representation of each existing object in the index as quoted parameters, separated by commas. If no parameters are given to Expand, the entire index will be used. If only the begin # is used, the rest of the index, beginning with the element # specified, will be used. If the length is additionally given, that number of elements from the index will be used, beginning with the element # specified as the beginning.

Methods

  • Remove[#]: Removes a single element from the index, by ID
  • RemoveByQuery[uint query_id]: Erases any elements in the index matching the given Query
  • RemoveByQuery[uint query_id,bool remove_MATCHES]: Erases any elements in the index that either match or do not match the given Query
  • Collapse: Removes gaps in the index (from removal of elements) by shifting elements toward 1
  • Move[#,#]: Moves an element to a new position in the index, by ID numbers. If an element exists in the new position, it is destroyed
  • Swap[#,#]: Swaps two positions in the index
  • Set[#,...]: Creates a new element in the index at the given position (destroying the previous element, if it existed). The additional parameters will be passed to the object initialization routine for the index sub-type, and an object will be created.
  • Resize[#]: Resizes the index such that it will hold at least this number of elements.
  • Insert[...]: Inserts an element in the index. The parameters will be passed to the object initialization routine for the index sub-type, and an object will be created. The index will be resized to fit the new object if necessary.

Examples

variable index:string VarName
VarName:Insert[one]
VarName:Insert[two]
VarName:Insert[three]
echo ${VarName.Get[1]} -- same as ${VarName[1]} because index supports it
echo ${VarName.Get[2]} -- same as ${VarName[2]} because index supports it
echo ${VarName.Get[3]} -- same as ${VarName[3]} because index supports it

Example from ISXEVE. In this example, SolarSystemID and OwnerID are members of the Bookmark datatype, returned by GetBookmarks.

variable int QueryID
EVE:GetBookmarks[Bookmarks]

QueryID:Set[${LavishScript.CreateQuery[SolarSystemID != ${Me.SolarSystemID} && OwnerID != ${Me.Corp.ID}]}]

Bookmarks.RemoveByQuery[${QueryID}]
LavishScript:FreeQuery[${QueryID}]
Bookmarks:Collapse

See Also