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

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