Aztec® Programming Language
Version 1.1 Alpha 2

Copyright © 2010-2017, Aztec Development Group, All Rights Reserved

Download Aztec

Search        Contact Us

What a shot you would be...

If you could shoot at me...

With those angry eyes.

- Kenny Loggins and Jim Messina

 

aztec.util.List

public class List<T> from<Collection>

Base

Collection

List<>

The List class is a "template" based class that takes a class name as an argument to indicate what type of class is being stored in the list. Once a specific instance of the List<> is created (simply by using It in code), the class provides a general purpose dynamic List class which can only hold that particular type of object (or an object whose type is derived from the that type). It is derived from Collection, so satisfies all the requirements that entails.

 

This class is intended for use with Aztec classes that are not primitive (int, float, etc.). There are special template based list classes for primitives and primitive references, PrimitiveList<> and PrimitiveRefList<>.

 

The beauty of the template based List<> classes versus the ObjectList class is that the template based implementation is built so the the system takes only a particular type of data to store in the list, and when an item is retrieved, the type of data is known by the compiler, so the caller gets a version of the "GetItem()" method specific to the data type being contained in the List<>, so no extra effort is required to change the return type to the desired type.

 

The template class is not usable by itself, and an implementation of the class must be created, using a valid Aztec class, in order to use the List<> class. The creation of a single implementation of the List<> template class can occur anywhere in Aztec code where a class can be used.

 

Note that the description of the List<> class below uses "T" as the placeholder in the class definition. It will be used throughout the class as a method argument and a retun type. When a specific implementation of the List<> class is created, the "T" will be replaced with the class that was passed into the List<> class definition.

 

List<> Methods

List() Constructor for the List<> class
Size() Returns number of items in the list
AddItem() Adds an item to the end of the list
InsertItem() Inserts an item anywhere in the list using one based position
SetItem() Sets the object reference at the specified one based position
GetItem() Gets the item at the specified one based position
RemoveItem() Removes the item from the list at the one based position and returns reference
GotoTop() Moves internal "pointer" to top of list
GotoBottom() Moves internal "pointer" to bottom of list
GetCurrentItem() Gets "current" object in collection and move pointer position
IsCurrentValid() Returns true if the "pointer" currently points at a valid position
Clear() Clears the entire list

Derived Classes

See Also

 


List()

public method List()

Parameters

None

Return Value

None

Description

Constructor for the List<> class.

 

List<> Class


Size()

public virtual method<int> Size()

Parameters

None

Return Value

Returns size of collection

Description

This method returns the total number of objects currently stored in the list.

 

List<> Class


AddItem()

public method AddItem(T Object)

Parameters

Object

Reference to object to be added to list

Return Value

None

Description

This method adds the specified object reference to the end of the list. The storage for the list is handled internally, and automatically grows the list if necessary. The user of the class doesn't need to worry about any of the details.

 

This method will fire a MemoryException if the system runs out of memory while satisfying the request.

 

List<> Class


InsertItem()

public method InsertItem(int Position, T Object)

Parameters

Position

One based position of insert

Object

Reference to object to be added to list

Return Value

None

Description

This method inserts the specified object reference before the one based position which is passed in. This method will fire a MemoryException if the system runs out of memory while satisfying the request.

 

List<> Class


SetItem()

public method SetItem(int Position, T Object)

Parameters

Position

One based position

Object

Reference to object to be set in the list

Return Value

None

Description

This method sets the specified object reference at the one based position which is passed in. If the position is greater than the current size of the list, the method will grow the size of the list, and fill in all slots between the "old size" and the "new size" with null. Then the specified Object reference is placed at the one based position in the list.

 

This method will fire a MemoryException if the system runs out of memory while satisfying the request.

 

List<> Class


GetItem()

public method<T> GetItem(int Position)

Parameters

Position

One based position

Return Value

Object reference at specified position

Description

This method returns the object reference at the specified one based position in the list. If the position is not valid (less than one or greater than the current size of the list), a value of null is returned.

 

List<> Class


RemoveItem()

public method<T> RemoveItem(int Position)

Parameters

Position

One based position

Return Value

Object reference being removed

Description

This method removes the object reference at the specified one based position from the list and returns the reference being removed. If the position is not valid (less than one or greater than the current size of the list), the list is not modified and a value of null is returned.

 

List<> Class


GotoTop()

public virtual method GotoTop()

Parameters

None

Return Value

None

Description

This method moves the internal "pointer" to the top of the list. The "GetCurrent()" method returns the object which is at the current pointer location.

 

List<> Class


GotoBottom()

public virtual method GotoBottom()

Parameters

None

Return Value

None

Description

This method moves the internal "pointer" to the bottom of the list. The "GetCurrent()" method returns the object which is at the current pointer location.

 

List<> Class


GetCurrentItem()

public virtual method<T> GetCurrentItem(bool Forward = true)

Parameters

None

Return Value

Reference to current item

Description

This method returns a reference to the object at the current "pointer" location within the list.

 

If the Forward flag is true, the current pointer location is then advanced to the next object in the list. If currently at the last position, the pointer is advanced to a "null" position.

 

If the forward flag is false, the current pointer is moved to the previous object in the list. If currently at the first position, the pointer is advanced to the "null" position.

 

If the pointer ends up at the "null" position, the next "GetCurrentItem()" call will return null. The "GotoTop()" or "GotoBottom()" method must be used to reset the pointer to a valid position.

 

If the collection is empty, this method also returns null.

 

List<> Class


IsCurrentValid()

public virtual method<bool> IsCurrentValid()

Parameters

None

Return Value

True if current position is valid

Description

Virtual method to return true if the "current" pointer within the list points at a valid position, and returns false if not. If the list is empty, or if the end of the list has been surpassed by making a "GetCurrentItem()" call at the end of the list, the current "pointer" does not point at a valid position (and GetCurrentItem() returns null), so this method returns false.

 

List<> Class


Clear()

public virtual method Clear()

Parameters

None

Return Value

None

Description

This method clears all items from the list.

 

List<> Class

 

Copyright © 2010-2017

Aztec Development Group

All Rights Reserved

Download Aztec