| Solstice documentation | Contained in the Solstice distribution. |
Solstice::Model::List - Superclass for classes that need to be both a List and a Model.
use Solstice::Model::List;;
my $model = Solstice::Model::List->new();
None by default.
Creates and returns an empty Solstice::Model::List object.
Removes all entries from the List object.
Reverse the order of the entries in the List.
Adds an element to the end of the List.
Remove the last element in the List and return it.
Adds an element to the front of the List.
Remove the first element in the List and return it.
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.
Replace an element in the List. It is 0 indexed. If successful, the replaced element is returned.
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.
This will remove an element from the List, at the index given. It is 0 indexed. If successful, the removed element is returned.
This is an empty method meant for overriding by subclasses
Catalyst Research & Development Group, <catalyst@u.washington.edu>
$Revision: 83 $
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.
| Solstice documentation | Contained in the Solstice distribution. |
package Solstice::Model::List; # $Id: List.pm 83 2006-03-14 06:51:35Z jlaney $
use strict; use warnings; use 5.006_000; use base qw( Solstice::Model Solstice::List ); our ($VERSION) = ('$Revision: 2065 $' =~ /^\$Revision:\s*([\d.]*)/); use constant TRUE => 1; use constant FALSE => 0; use constant SUCCESS => 1; use constant FAIL => 0;
sub new { my ($class) = @_; my $self = $class->SUPER::new(); $self->_clear(); return $self; }
sub clear { my ($self) = @_; $self->_listRead(); $self->_listChanged(); return $self->Solstice::List::clear(); }
sub reverse { my ($self) = @_; $self->_listRead(); $self->_listChanged(); return $self->Solstice::List::reverse(); }
sub push { my ($self, $element) = @_; $self->_listRead(); $self->_listChanged(); return $self->Solstice::List::push($element); }
sub pop { my ($self) = @_; $self->_listRead(); $self->_listChanged(); return $self->Solstice::List::pop(); }
sub unshift { my ($self, $element) = @_; $self->_listRead(); $self->_listChanged(); return $self->Solstice::List::unshift($element); }
sub shift { my ($self) = @_; $self->_listRead(); $self->_listChanged(); return $self->Solstice::List::shift(); }
sub add { my $self = CORE::shift; $self->_listRead(); $self->onAdd(); my $status = $self->Solstice::List::add(@_); $self->_listChanged() if $status; return $status; } sub onAdd { return TRUE; }
sub addList { my $self = CORE::shift; $self->_listRead(); my $status = $self->Solstice::List::addList(@_); $self->_listChanged() if $status; return $status; }
sub replace { my ($self, $index, $element) = @_; $self->_listRead(); $self->onReplace(); my $return = $self->Solstice::List::replace($index, $element); $self->_listChanged(); return $return; } sub onReplace { return TRUE; } sub exists { my ($self, $index) = @_; $self->_listRead(); return $self->Solstice::List::exists($index); } sub get { my ($self, $index) = @_; $self->_listRead(); return $self->Solstice::List::get($index); } sub getAll { my ($self) = @_; $self->_listRead(); return $self->Solstice::List::getAll(); } sub isEmpty { my ($self) = @_; $self->_listRead(); return $self->Solstice::List::isEmpty(); } sub size { my ($self) = @_; $self->_listRead(); return $self->Solstice::List::size(); } sub iterator { my ($self) = @_; $self->_listRead(); return $self->Solstice::List::iterator(); }
sub move { my ($self, $oldindex, $newindex) = @_; $self->_listRead(); $self->onMove(); my $status = $self->Solstice::List::move($oldindex, $newindex); $self->_listChanged() if $status; return $status; }
sub onMove { return TRUE; }
sub remove { my ($self, $index) = @_; $self->_listRead(); $self->onRemove($index); my $return = $self->Solstice::List::remove($index); $self->_listChanged(); return $return; }
sub onRemove { return TRUE; }
sub _clear { my $self = CORE::shift; return $self->Solstice::List::clear(); }
sub _add { my $self = CORE::shift; return $self->Solstice::List::add(@_); }
sub _addList { my $self = CORE::shift; return $self->Solstice::List::addList(@_); }
sub _listChanged { my $self = CORE::shift; $self->_taint(); } sub _listRead { #override me! } 1; __END__