annotate Lib/IMPL/Object/List.pm @ 3:2e546a5175dd

in developing
author Sergey
date Tue, 11 Aug 2009 17:45:52 +0400
parents 78cd38551534
children e59f44f75f20
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);
3
2e546a5175dd in developing
Sergey
parents: 2
diff changeset
6 use IMPL::Exception;
2
78cd38551534 in develop
Sergey
parents:
diff changeset
7
78cd38551534 in develop
Sergey
parents:
diff changeset
8 sub as_list {
78cd38551534 in develop
Sergey
parents:
diff changeset
9 return $_[0];
78cd38551534 in develop
Sergey
parents:
diff changeset
10 }
78cd38551534 in develop
Sergey
parents:
diff changeset
11
3
2e546a5175dd in developing
Sergey
parents: 2
diff changeset
12 sub CTOR {
2e546a5175dd in developing
Sergey
parents: 2
diff changeset
13 my ($this,$data) = @_;
2e546a5175dd in developing
Sergey
parents: 2
diff changeset
14
2e546a5175dd in developing
Sergey
parents: 2
diff changeset
15 if ($data) {
2e546a5175dd in developing
Sergey
parents: 2
diff changeset
16 die new IMPL::InvalidArgumentException("The parameter should be a reference to an array") unless UNIVERSAL::isa($data,"ARRAY");
2e546a5175dd in developing
Sergey
parents: 2
diff changeset
17 @$this = @$data;
2e546a5175dd in developing
Sergey
parents: 2
diff changeset
18 }
2e546a5175dd in developing
Sergey
parents: 2
diff changeset
19 }
2e546a5175dd in developing
Sergey
parents: 2
diff changeset
20
2
78cd38551534 in develop
Sergey
parents:
diff changeset
21 sub Append {
78cd38551534 in develop
Sergey
parents:
diff changeset
22 push @{$_[0]}, @_{1 .. @$_-1};
78cd38551534 in develop
Sergey
parents:
diff changeset
23 }
78cd38551534 in develop
Sergey
parents:
diff changeset
24
78cd38551534 in develop
Sergey
parents:
diff changeset
25 sub RemoveLast {
78cd38551534 in develop
Sergey
parents:
diff changeset
26 return pop @{$_[0]};
78cd38551534 in develop
Sergey
parents:
diff changeset
27 }
78cd38551534 in develop
Sergey
parents:
diff changeset
28
78cd38551534 in develop
Sergey
parents:
diff changeset
29 sub AddFirst {
78cd38551534 in develop
Sergey
parents:
diff changeset
30 return unshift @{$_[0]}, $_[1];
78cd38551534 in develop
Sergey
parents:
diff changeset
31 }
78cd38551534 in develop
Sergey
parents:
diff changeset
32
78cd38551534 in develop
Sergey
parents:
diff changeset
33 sub RemoveFirst {
78cd38551534 in develop
Sergey
parents:
diff changeset
34 return shift @{$_[0]};
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 Count {
78cd38551534 in develop
Sergey
parents:
diff changeset
38 return scalar @{$_[0]};
78cd38551534 in develop
Sergey
parents:
diff changeset
39 }
78cd38551534 in develop
Sergey
parents:
diff changeset
40
78cd38551534 in develop
Sergey
parents:
diff changeset
41 sub InsertAt {
78cd38551534 in develop
Sergey
parents:
diff changeset
42 my ($this,$index,@val) = @_;
78cd38551534 in develop
Sergey
parents:
diff changeset
43
78cd38551534 in develop
Sergey
parents:
diff changeset
44 splice @$this,$index,0,@val;
78cd38551534 in develop
Sergey
parents:
diff changeset
45 }
78cd38551534 in develop
Sergey
parents:
diff changeset
46
78cd38551534 in develop
Sergey
parents:
diff changeset
47 sub RemoveAt {
78cd38551534 in develop
Sergey
parents:
diff changeset
48 my ($this,$index,$count) = @_;
78cd38551534 in develop
Sergey
parents:
diff changeset
49
78cd38551534 in develop
Sergey
parents:
diff changeset
50 $count ||= 1;
78cd38551534 in develop
Sergey
parents:
diff changeset
51
78cd38551534 in develop
Sergey
parents:
diff changeset
52 return splice @$this,$index,$count;
78cd38551534 in develop
Sergey
parents:
diff changeset
53 }
78cd38551534 in develop
Sergey
parents:
diff changeset
54
78cd38551534 in develop
Sergey
parents:
diff changeset
55 1;