mglib

Personal IDL library for M. Galloy

single page | use frames     summary     class     fields     routine details     file attributes

collection/

mgcoarraylist__define.pro


An array list is a way to have an arbitrary length list of any particular IDL variable (but all elements must be the same type). An MGcoArrayList implements the same interface as IDL_Container, but can contain any IDL type.

Examples

For example:

a = obj_new('MGcoArrayList', type=7) a->add, 'a' a->add, ['b', 'c', 'd'] print, a->count() print, a->get(/all) print, a->get(position=1) obj_destroy, a

Author information

Author

Michael Galloy

Version

1.1

Class description for mgcoarraylist

Inheritance

All ancestor classes: mgcoabstractlist idl_object

Properties

Properties in mgcoarraylist

_ref_extra get

keywords to MGcoAbstractList::getProperty

block_size get set init

initial size of the data array; defaults to 1000 if not specified

count get

number of elements in the array list

example get init

type defined by an example instead of a type code (required for array lists of structures)

type get set init

type code as in SIZE function to specify the type of elements in the list; TYPE or EXAMPLE keyword must be used when initializing the array list

Routines

Methods inherited from idl_object

Methods inherited from mgcoabstractlist

Routines from mgcoarraylist__define.pro

result = mgcoarraylist::_overloadBracketsRightSide(isRange, ss1, ss2, ss3, ss4, ss5, ss6, ss7, ss8)

Allows array index access with brackets.

mgcoarraylist::_overloadBracketsLeftSide, objref, value, isRange, ss1, ss2, ss3, ss4, ss5, ss6, ss7, ss8

Allows setting values of the array list by array index.

result = mgcoarraylist::_overloadPlus(left, right)

Concatenate two array lists.

result = mgcoarraylist::_overloadAsterisk(left, right)

Repeat an array list a given number of times.

result = mgcoarraylist::_overloadForeach(value [, key])

Allows an array list to be used in a FOREACH loop.

result = mgcoarraylist::_overloadPrint()

Returns the elements to print.

result = mgcoarraylist::_overloadHelp(varname)

Returns a string describing the array list.

result = mgcoarraylist::_overloadSize()

Returns the number of elements in the array list.

mgcoarraylist::getProperty, type=type, block_size=block_size, example=example, count=count, _ref_extra=_ref_extra

Get properties of the list.

mgcoarraylist::setProperty, type=type, block_size=block_size

Set properties of the list.

mgcoarraylist::remove [, elements] [, position=long] [, /all]

Remove specified elements from the list.

mgcoarraylist::move, source, destination

Move an element of the list to another position.

result = mgcoarraylist::isContained(elements [, position=long])

Determines whether a list contains specified elements.

mgcoarraylist::add, elements [, position=long/lonarr]

Add elements to the list.

result = mgcoarraylist::get( [/all] [, position=long/lonarr] [, count=integer] [, isa=string/strarr])

Get elements of the list.

result = mgcoarraylist::count()

Returns the number of elements in the list.

result = mgcoarraylist::iterator()

Creates an iterator to iterate through the elements of the ArrayList.

mgcoarraylist::cleanup

Cleanup list resources.

result = mgcoarraylist::init( [elements], type=type, example=example, block_size=block_size)

Create a list.

mgcoarraylist__define

Define member variables.

Routine details

top mgcoarraylist::_overloadBracketsRightSide

result = mgcoarraylist::_overloadBracketsRightSide(isRange, ss1, ss2, ss3, ss4, ss5, ss6, ss7, ss8)

Allows array index access with brackets.

Return value

elements of the same type as the array list

Parameters

isRange
ss1
ss2
ss3
ss4
ss5
ss6
ss7
ss8

Examples

Try:

IDL> a = obj_new('MGcoArrayList', type=4) IDL> a->add, findgen(10) IDL> print, a[0:5:1]

Other attributes

Bugs:

when using an index array to index an array list, out-of-bounds indices larger than the last element's index are not handled property -- they do not return the last element (negative indices will return the first element, though)

top mgcoarraylist::_overloadBracketsLeftSide

mgcoarraylist::_overloadBracketsLeftSide, objref, value, isRange, ss1, ss2, ss3, ss4, ss5, ss6, ss7, ss8

Allows setting values of the array list by array index.

Parameters

objref
value
isRange
ss1
ss2
ss3
ss4
ss5
ss6
ss7
ss8

Examples

Try:

IDL> a = obj_new('MGcoArrayList', type=4) IDL> a->add, findgen(10) IDL> a[0:-3:2] = findgen(4) IDL> print, a 0.00000 1.00000 1.00000 3.00000 2.00000 5.00000 3.00000 7.00000 8.00000 9.00000

top mgcoarraylist::_overloadPlus

result = mgcoarraylist::_overloadPlus(left, right)

Concatenate two array lists.

Return value

MGcoArrayList object

Parameters

left
right

top mgcoarraylist::_overloadAsterisk

result = mgcoarraylist::_overloadAsterisk(left, right)

Repeat an array list a given number of times.

Return value

MGcoArrayList object

Parameters

left
right

top mgcoarraylist::_overloadForeach

result = mgcoarraylist::_overloadForeach(value [, key])

Allows an array list to be used in a FOREACH loop.

Return value

1 if there is an item to return, 0 if not

Parameters

value out required type=list type

value to return as the loop

key in out optional type=undefined/long

key is undefined for first element, otherwise the index of the last element returned

top mgcoarraylist::_overloadPrint

result = mgcoarraylist::_overloadPrint()

Returns the elements to print. Called by PRINT to determine what should be displayed.

Return value

array of elements of the type of the array list

top mgcoarraylist::_overloadHelp

result = mgcoarraylist::_overloadHelp(varname)

Returns a string describing the array list. Called by the HELP routine.

Return value

string

Parameters

varname in required type=string

name of the variable to use when outputting help information

top mgcoarraylist::_overloadSize

result = mgcoarraylist::_overloadSize()

Returns the number of elements in the array list. Called by SIZE to retrieve information about the size of the variable.

Return value

long

top mgcoarraylist::getProperty

mgcoarraylist::getProperty, type=type, block_size=block_size, example=example, count=count, _ref_extra=_ref_extra

Get properties of the list.

Keywords

type

type code as in SIZE function to specify the type of elements in the list; TYPE or EXAMPLE keyword must be used when initializing the array list

block_size

initial size of the data array; defaults to 1000 if not specified

example

type defined by an example instead of a type code (required for array lists of structures)

count

number of elements in the array list

_ref_extra

keywords to MGcoAbstractList::getProperty

top mgcoarraylist::setProperty

mgcoarraylist::setProperty, type=type, block_size=block_size

Set properties of the list.

Keywords

type

type code as in SIZE function to specify the type of elements in the list; TYPE or EXAMPLE keyword must be used when initializing the array list

block_size

initial size of the data array; defaults to 1000 if not specified

top mgcoarraylist::remove

mgcoarraylist::remove [, elements] [, position=long] [, /all]

Remove specified elements from the list.

Parameters

elements in optional type=type of list

elements of the list to remove

Keywords

position in optional type=long

set to a scalar or vector array of indices to remove from the list

all in optional type=boolean

set to remove all elements of the list

top mgcoarraylist::move

mgcoarraylist::move, source, destination

Move an element of the list to another position.

Parameters

source in required type=long

index of the element to move

destination in required type=long

index of position to move element

top mgcoarraylist::isContained

result = mgcoarraylist::isContained(elements [, position=long])

Determines whether a list contains specified elements.

Return value

1B if contained or 0B if otherwise

Parameters

elements in required type=type of list

scalar or vector of elements of the same type as the list

Keywords

position out optional type=long

set to a named variable that will return the position of the first instance of the corresponding element of the specified elements

top mgcoarraylist::add

mgcoarraylist::add, elements [, position=long/lonarr]

Add elements to the list.

Parameters

elements in required type=list type

scalar or vector array of the same type as the list

Keywords

position in optional type=long/lonarr default=end of list

index or index array to insert elements at; if array, must match number of elements

top mgcoarraylist::get

result = mgcoarraylist::get( [/all] [, position=long/lonarr] [, count=integer] [, isa=string/strarr])

Get elements of the list.

Return value

element(s) of the list or -1L if no elements to return

Keywords

all in optional type=boolean

set to return all elements

position in optional type=long/lonarr

set to an index or an index array of elements to return; defaults to 0 if ALL keyword not set

count out optional type=integer

set to a named variable to get the number of elements returned by this function

isa in optional type=string/strarr

classname(s) of objects to return; only allowable if list type is object

top mgcoarraylist::count

result = mgcoarraylist::count()

Returns the number of elements in the list.

Return value

long integer

top mgcoarraylist::iterator

result = mgcoarraylist::iterator()

Creates an iterator to iterate through the elements of the ArrayList. The destruction of the iterator is the responsibility of the caller of this method.

Return value

MGcoArrayListIterator object

top mgcoarraylist::cleanup

mgcoarraylist::cleanup

Cleanup list resources.

top mgcoarraylist::init

result = mgcoarraylist::init( [elements], type=type, example=example, block_size=block_size)

Create a list.

Return value

1B for succes, 0B otherwise

Parameters

elements in optional type=any

scalar or array of original value(s) of the array list

Keywords

type

type code as in SIZE function to specify the type of elements in the list; TYPE or EXAMPLE keyword must be used when initializing the array list

example

type defined by an example instead of a type code (required for array lists of structures)

block_size

initial size of the data array; defaults to 1000 if not specified

top mgcoarraylist__define

object, collection

mgcoarraylist__define

Define member variables.

File attributes

Modification date: Wed May 14 15:07:14 2014
Lines: 377
Docformat: rst rst
Personal library of Michael Galloy
Contact me if you have enhancement requests or bug fixes.