comparison Lib/IMPL/Object/List.pm @ 2:78cd38551534

in develop
author Sergey
date Mon, 10 Aug 2009 17:39:08 +0400
parents
children 2e546a5175dd
comparison
equal deleted inserted replaced
1:3b418b134d8c 2:78cd38551534
1 package IMPL::Object::List;
2 use strict;
3 use warnings;
4
5 use base qw(IMPL::Object::ArrayObject);
6
7 sub as_list {
8 return $_[0];
9 }
10
11 sub Append {
12 push @{$_[0]}, @_{1 .. @$_-1};
13 }
14
15 sub RemoveLast {
16 return pop @{$_[0]};
17 }
18
19 sub AddFirst {
20 return unshift @{$_[0]}, $_[1];
21 }
22
23 sub RemoveFirst {
24 return shift @{$_[0]};
25 }
26
27 sub Count {
28 return scalar @{$_[0]};
29 }
30
31 sub InsertAt {
32 my ($this,$index,@val) = @_;
33
34 splice @$this,$index,0,@val;
35 }
36
37 sub RemoveAt {
38 my ($this,$index,$count) = @_;
39
40 $count ||= 1;
41
42 return splice @$this,$index,$count;
43 }
44
45 1;