diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2001-09-09 22:04:11 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2001-09-09 22:04:11 +0000 |
commit | c3f9c4537115a091b52f56681bb8321578dce74c (patch) | |
tree | 6af65295e002777b772dce93044f042729f7fc0b /MDK/Common/DataStructure.pm | |
parent | ad6cb8f0d2ffa516fb95a657324c2cb2dba805bd (diff) | |
download | perl-MDK-Common-c3f9c4537115a091b52f56681bb8321578dce74c.tar perl-MDK-Common-c3f9c4537115a091b52f56681bb8321578dce74c.tar.gz perl-MDK-Common-c3f9c4537115a091b52f56681bb8321578dce74c.tar.bz2 perl-MDK-Common-c3f9c4537115a091b52f56681bb8321578dce74c.tar.xz perl-MDK-Common-c3f9c4537115a091b52f56681bb8321578dce74c.zip |
- DataStructure::uniq : keep the order
- String::warp_text : fixed
Diffstat (limited to 'MDK/Common/DataStructure.pm')
-rw-r--r-- | MDK/Common/DataStructure.pm | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/MDK/Common/DataStructure.pm b/MDK/Common/DataStructure.pm index ecdb45f..83e49f1 100644 --- a/MDK/Common/DataStructure.pm +++ b/MDK/Common/DataStructure.pm @@ -57,7 +57,7 @@ is the scalar undefined or is the hash empty =item uniq(LIST) -returns the list with no duplicates +returns the list with no duplicates (keeping the first elements) =item difference2(ARRAY REF, ARRAY REF) @@ -111,7 +111,7 @@ sub deref { ref $_[0] eq "ARRAY" ? @{$_[0]} : ref $_[0] eq "HASH" ? %{$_[0]} : $ sub is_empty_array_ref { my $a = shift; !defined $a || @$a == 0 } sub is_empty_hash_ref { my $a = shift; !defined $a || keys(%$a) == 0 } -sub uniq { my %l; @l{@_} = (); keys %l } +sub uniq { my %l; $l{$_} = 1 foreach @_; grep { delete $l{$_} } @_ } sub difference2 { my %l; @l{@{$_[1]}} = (); grep { !exists $l{$_} } @{$_[0]} } sub intersection { my (%l, @m); @l{@{shift @_}} = (); foreach (@_) { @m = grep { exists $l{$_} } @$_; %l = (); @l{@m} = (); } keys %l } |