Mercurial > pub > Impl
diff Lib/IMPL/Object/List.pm @ 49:16ada169ca75
migrating to the Eclipse IDE
author | wizard@linux-odin.local |
---|---|
date | Fri, 26 Feb 2010 10:49:21 +0300 |
parents | 818c74b038ae |
children | 76b878ad6596 |
line wrap: on
line diff
--- a/Lib/IMPL/Object/List.pm Fri Feb 26 01:43:42 2010 +0300 +++ b/Lib/IMPL/Object/List.pm Fri Feb 26 10:49:21 2010 +0300 @@ -1,72 +1,72 @@ -package IMPL::Object::List; -use strict; -use warnings; - -use base qw(IMPL::Object::ArrayObject); -use IMPL::Exception; - -sub as_list { - return wantarray ? @{$_[0]} : $_[0]; -} - -sub CTOR { - my ($this,$data) = @_; - - if ($data) { - die new IMPL::InvalidArgumentException("The parameter should be a reference to an array") unless UNIVERSAL::isa($data,"ARRAY"); - @$this = @$data; - } -} - -sub Append { - push @{$_[0]}, @_[1 .. $#_]; -} - -sub RemoveLast { - return pop @{$_[0]}; -} - -sub AddFirst { - return unshift @{$_[0]}, $_[1]; -} - -sub RemoveFirst { - return shift @{$_[0]}; -} - -sub Count { - return scalar @{$_[0]}; -} - -sub InsertAt { - my ($this,$index,@val) = @_; - - splice @$this,($index||0),0,@val; -} - -sub RemoveAt { - my ($this,$index,$count) = @_; - - $count ||= 1; - - return splice @$this,$index,$count; -} - -sub RemoveItem { - my ($this,$item) = @_; - - @$this = grep $_ != $item, @$this; - - return $this; -} - -sub RemoveItemStr { - my ($this,$item) = @_; - - @$this = grep $_ ne $item, @$this; - - return $this; -} - - -1; +package IMPL::Object::List; +use strict; +use warnings; + +use base qw(IMPL::Object::ArrayObject); +use IMPL::Exception; + +sub as_list { + return wantarray ? @{$_[0]} : $_[0]; +} + +sub CTOR { + my ($this,$data) = @_; + + if ($data) { + die new IMPL::InvalidArgumentException("The parameter should be a reference to an array") unless UNIVERSAL::isa($data,"ARRAY"); + @$this = @$data; + } +} + +sub Append { + push @{$_[0]}, @_[1 .. $#_]; +} + +sub RemoveLast { + return pop @{$_[0]}; +} + +sub AddFirst { + return unshift @{$_[0]}, $_[1]; +} + +sub RemoveFirst { + return shift @{$_[0]}; +} + +sub Count { + return scalar @{$_[0]}; +} + +sub InsertAt { + my ($this,$index,@val) = @_; + + splice @$this,($index||0),0,@val; +} + +sub RemoveAt { + my ($this,$index,$count) = @_; + + $count ||= 1; + + return splice @$this,$index,$count; +} + +sub RemoveItem { + my ($this,$item) = @_; + + @$this = grep $_ != $item, @$this; + + return $this; +} + +sub RemoveItemStr { + my ($this,$item) = @_; + + @$this = grep $_ ne $item, @$this; + + return $this; +} + + +1;