The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Solstice::List - A basic list object.

SYNOPSIS

  use List;

  my $list = new List;

  $list->add($element);
  $list->add($position, $element);
  $element = $list->get($position);
  $list->remove($position);
  $list->move($oldindex, $newindex);
  $isempty = $list->isEmpty();
  my $size = $list->size();
  $list->clear();

  my $iterator = $list->iterator();
  while ($iterator->hasNext()) {
    my $element = $iterator->next();
  }

DESCRIPTION

Provides a set of functionality for creating and manipulating lists.

Export

No symbols exported.

Methods

new ([$list])

Creates and returns an empty List object. If passed, $list can be either a Solstice::List object, or a reference to an array.

clear()

Removes all entries from the List object.

reverse()

Reverse the order of the entries in the List.

push($element)

Adds an element to the end of the List.

pop()

Remove the last element in the List and return it.

unshift($element)

Adds an element to the front of the List.

shift()

Remove the first element in the List and return it.

add ([$index,] $element)

Adds an element to the List. If no index is given it will be added to the end of the List, otherwise it will be placed at the index given, and the other elements will be shifted out of the way. Passing $index equal to the list size is also permissible. It is 0 indexed.

addList($list)

Append items in $list to the List. $list can be either a Solstice::List object, or a reference to an array.

replace($index, $element)

Replace an element in the List. It is 0 indexed. if successful, the replaced element is returned.

contains($element)

Not implemented.

exists($index)

Returns TRUE if the passed $index exists in the List, FALSE otherwise. It is 0 indexed.

get($index)

Returns the element in the List at the given index. It is 0 indexed.

getAll()

Returns the List.

indexOf ($element)

Not implemented.

isEmpty ()

Returns a boolean describing whether the internal List array is empty.

lastIndexOf ($element)

Not implemented.

size ()

Returns the size of the internal List. This is also the index of the 'next' position that an element can be added to, if you want to explicitly place it at the end of the List.

subList ($from, $to)

Returns a view of the portion of this List between the specified fromIndex, inclusive, and toIndex, exclusive

Not implemented.

move ($oldindex, $newindex)

This will move an element from one position in the List to another. It is 0 indexed. Note: This will not reset any iterators, so there may be some confusion if you iterate over a List you are still manipulating.

remove ($index)

This will remove an element from the List, at the index given. It is 0 indexed. If successful, the removed element is returned.

iterator ()

Creates and returns a new iterator over the List.

Private Methods

_init([$input])

Initialize the List by clearing it.

_getDataArray()

Private method for the iterator to use when sorting.

_setDataArray(\@data)

Private method for the iterator to use when sorting.

List::Iterator::new ($list)

Creates and returns a new iterator over the list.

List::Iterator::sort([$anonymous_sub_ref])

Sorts the values that will come out of the iterator. Resets the position of the iterator.

List::Iterator::hasNext ()

Returns a boolean describing whether there is another element in the list after the current cursor position.

List::Iterator::next ()

Returns the next element in the list, and increments the cursor.

List::Iterator::index ()

Returns the current cursor position.

List::Iterator::setStartIndex ()

Moves the pointer of the list to the given position

List::Iterator::setEndIndex ()

Sets a cutoff position at which the iterator will stop looping

Modules Used

Carp.

AUTHOR

Catalyst Group, <catalyst@u.washington.edu>

VERSION

$Revision: 2065 $

COPYRIGHT

Copyright 1998-2007 Office of Learning Technologies, University of Washington

Licensed under the Educational Community License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.opensource.org/licenses/ecl1.php

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.