Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package perl-Array-Unique for openSUSE:Factory checked in at 2023-06-03 00:07:11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Array-Unique (Old) and /work/SRC/openSUSE:Factory/.perl-Array-Unique.new.15902 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Array-Unique" Sat Jun 3 00:07:11 2023 rev:5 rq:1090359 version:0.09 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Array-Unique/perl-Array-Unique.changes 2013-01-17 13:18:24.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Array-Unique.new.15902/perl-Array-Unique.changes 2023-06-03 00:07:19.570025236 +0200 @@ -1,0 +2,12 @@ +Tue May 30 03:06:09 UTC 2023 - Tina Müller <timueller+p...@suse.de> + +- updated to 0.09 + see /usr/share/doc/packages/perl-Array-Unique/Changes + + 0.09 2023.05.29 + - Move to GitHub + - Add GitHub Actions + - Add links to GitHub + - Add version number to each module + +------------------------------------------------------------------- Old: ---- Array-Unique-0.08.tar.gz New: ---- Array-Unique-0.09.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Array-Unique.spec ++++++ --- /var/tmp/diff_new_pack.Z5yC30/_old 2023-06-03 00:07:19.982027669 +0200 +++ /var/tmp/diff_new_pack.Z5yC30/_new 2023-06-03 00:07:19.986027693 +0200 @@ -1,7 +1,7 @@ # # spec file for package perl-Array-Unique # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,26 +12,22 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # +%define cpan_name Array-Unique Name: perl-Array-Unique -Version: 0.08 +Version: 0.09 Release: 0 -%define cpan_name Array-Unique +License: Artistic-1.0 OR GPL-1.0-or-later Summary: Tie-able array that allows only unique values -License: GPL-2.0+ or Artistic-1.0 -Group: Development/Libraries/Perl -Url: http://search.cpan.org/dist/Array-Unique/ -#Source: http://www.cpan.org/authors/id/S/SZ/SZABGAB/Array-Unique-%%{version}.tar.gz -Source: %{cpan_name}-%{version}.tar.gz +URL: https://metacpan.org/release/%{cpan_name} +Source0: https://cpan.metacpan.org/authors/id/S/SZ/SZABGAB/%{cpan_name}-%{version}.tar.gz +BuildArch: noarch BuildRequires: perl BuildRequires: perl-macros -BuildRequires: perl(Module::Build) -BuildRequires: perl(Test::More) >= 0.47 -BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildArch: noarch +BuildRequires: perl(Module::Build) >= 0.420000 %{perl_requires} %description @@ -50,10 +46,10 @@ As a side effect the module does not allow undef as a value in the array. %prep -%setup -q -n %{cpan_name}-%{version} +%autosetup -n %{cpan_name}-%{version} %build -%{__perl} Build.PL installdirs=vendor +perl Build.PL installdirs=vendor ./Build build flags=%{?_smp_mflags} %check @@ -63,11 +59,7 @@ ./Build install destdir=%{buildroot} create_packlist=0 %perl_gen_filelist -%clean -%{__rm} -rf %{buildroot} - %files -f %{name}.files -%defattr(644,root,root,755) -%doc Changes README +%doc Changes README README.md %changelog ++++++ Array-Unique-0.08.tar.gz -> Array-Unique-0.09.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/Build.PL new/Array-Unique-0.09/Build.PL --- old/Array-Unique-0.08/Build.PL 2008-06-04 06:48:22.000000000 +0200 +++ new/Array-Unique-0.09/Build.PL 2023-05-29 19:28:42.000000000 +0200 @@ -17,6 +17,12 @@ build_requires => { 'Test::More' => 0.47, }, + meta_merge => { + resources => { + repository => 'https://github.com/szabgab/Array-Unique/', + bugtracker => 'https://github.com/szabgab/Array-Unique/issues' + } + }, ); $builder->create_build_script(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/Changes new/Array-Unique-0.09/Changes --- old/Array-Unique-0.08/Changes 2008-06-04 06:48:22.000000000 +0200 +++ new/Array-Unique-0.09/Changes 2023-05-29 19:28:42.000000000 +0200 @@ -1,5 +1,11 @@ Revision history for Perl extension Array::Unique. +0.09 2023.05.29 + - Move to GitHub + - Add GitHub Actions + - Add links to GitHub + - Add version number to each module + 0.08 2008 June 4 Mostly CPANTS gaming diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/MANIFEST new/Array-Unique-0.09/MANIFEST --- old/Array-Unique-0.08/MANIFEST 2008-06-04 06:48:22.000000000 +0200 +++ new/Array-Unique-0.09/MANIFEST 2023-05-29 19:28:42.000000000 +0200 @@ -1,17 +1,22 @@ +benchmark.pl +Build.PL Changes +dev.pl +lib/Array/Unique.pm +lib/Array/Unique/Hash.pm +lib/Array/Unique/IxHash.pm +lib/Array/Unique/Quick.pm +lib/Array/Unique/Std.pm Makefile.PL -Build.PL -MANIFEST -README +MANIFEST This list of files +META.json META.yml - +README +README.md t/01regular.t t/02class.t t/03unique.t t/04false.t - -lib/Array/Unique.pm - xt/critic.t xt/pod-coverage.t xt/pod.t diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/META.json new/Array-Unique-0.09/META.json --- old/Array-Unique-0.08/META.json 1970-01-01 01:00:00.000000000 +0100 +++ new/Array-Unique-0.09/META.json 2023-05-29 19:28:42.000000000 +0200 @@ -0,0 +1,69 @@ +{ + "abstract" : "Tie-able array that allows only unique values", + "author" : [ + "Gabor Szabo <ga...@pti.co.il>" + ], + "dynamic_config" : 1, + "generated_by" : "Module::Build version 0.4232", + "license" : [ + "perl_5" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : 2 + }, + "name" : "Array-Unique", + "prereqs" : { + "build" : { + "requires" : { + "Test::More" : "0.47" + } + }, + "configure" : { + "requires" : { + "Module::Build" : "0.42" + } + }, + "runtime" : { + "requires" : { + "perl" : "5.006" + } + } + }, + "provides" : { + "Array::Unique" : { + "file" : "lib/Array/Unique.pm", + "version" : "0.09" + }, + "Array::Unique::Hash" : { + "file" : "lib/Array/Unique/Hash.pm", + "version" : "0.09" + }, + "Array::Unique::IxHash" : { + "file" : "lib/Array/Unique/IxHash.pm", + "version" : "0.09" + }, + "Array::Unique::Quick" : { + "file" : "lib/Array/Unique/Quick.pm", + "version" : "0.09" + }, + "Array::Unique::Std" : { + "file" : "lib/Array/Unique/Std.pm", + "version" : "0.09" + } + }, + "release_status" : "stable", + "resources" : { + "bugtracker" : { + "web" : "https://github.com/szabgab/Array-Unique/issues" + }, + "license" : [ + "http://dev.perl.org/licenses/" + ], + "repository" : { + "url" : "https://github.com/szabgab/Array-Unique/" + } + }, + "version" : "0.09", + "x_serialization_backend" : "JSON::PP version 4.07" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/META.yml new/Array-Unique-0.09/META.yml --- old/Array-Unique-0.08/META.yml 2008-06-04 06:48:22.000000000 +0200 +++ new/Array-Unique-0.09/META.yml 2023-05-29 19:28:42.000000000 +0200 @@ -1,21 +1,39 @@ --- -name: Array-Unique -version: 0.08 +abstract: 'Tie-able array that allows only unique values' author: - 'Gabor Szabo <ga...@pti.co.il>' -abstract: Tie-able array that allows only unique values -license: perl -resources: - license: http://dev.perl.org/licenses/ -requires: - perl: 5.006 build_requires: - Test::More: 0.47 + Test::More: '0.47' +configure_requires: + Module::Build: '0.42' +dynamic_config: 1 +generated_by: 'Module::Build version 0.4232, CPAN::Meta::Converter version 2.150010' +license: perl +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: '1.4' +name: Array-Unique provides: Array::Unique: file: lib/Array/Unique.pm - version: 0.08 -generated_by: Module::Build version 0.2808 -meta-spec: - url: http://module-build.sourceforge.net/META-spec-v1.2.html - version: 1.2 + version: '0.09' + Array::Unique::Hash: + file: lib/Array/Unique/Hash.pm + version: '0.09' + Array::Unique::IxHash: + file: lib/Array/Unique/IxHash.pm + version: '0.09' + Array::Unique::Quick: + file: lib/Array/Unique/Quick.pm + version: '0.09' + Array::Unique::Std: + file: lib/Array/Unique/Std.pm + version: '0.09' +requires: + perl: '5.006' +resources: + bugtracker: https://github.com/szabgab/Array-Unique/issues + license: http://dev.perl.org/licenses/ + repository: https://github.com/szabgab/Array-Unique/ +version: '0.09' +x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/Makefile.PL new/Array-Unique-0.09/Makefile.PL --- old/Array-Unique-0.08/Makefile.PL 2008-06-04 06:48:22.000000000 +0200 +++ new/Array-Unique-0.09/Makefile.PL 2023-05-29 19:28:42.000000000 +0200 @@ -1,14 +1,15 @@ -# Note: this file was auto-generated by Module::Build::Compat version 0.03 +# Note: this file was auto-generated by Module::Build::Compat version 0.4232 +require 5.006; use ExtUtils::MakeMaker; WriteMakefile ( - 'NAME' => 'Array::Unique', - 'VERSION_FROM' => 'lib/Array/Unique.pm', - 'PREREQ_PM' => { - 'Test::More' => '0.47' - }, - 'INSTALLDIRS' => 'site', - 'EXE_FILES' => [], - 'PL_FILES' => {} - ) + 'NAME' => 'Array::Unique', + 'VERSION_FROM' => 'lib/Array/Unique.pm', + 'PREREQ_PM' => { + 'Test::More' => '0.47' + }, + 'INSTALLDIRS' => 'site', + 'EXE_FILES' => [], + 'PL_FILES' => {} +) ; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/README new/Array-Unique-0.09/README --- old/Array-Unique-0.08/README 2008-06-04 06:48:22.000000000 +0200 +++ new/Array-Unique-0.09/README 2023-05-29 19:28:42.000000000 +0200 @@ -1,13 +1,16 @@ NAME + Array::Unique - Tie-able array that allows only unique values SYNOPSIS + use Array::Unique; tie @a, 'Array::Unique'; - + Now use @a as a regular array. DESCRIPTION + This package lets you create an array which will allow only one occurrence of any value. @@ -17,141 +20,151 @@ You use the module via tie and once you tied your array to this module it will behave correctly. - Uniqueness is checked with the 'eq' operator so among other things it is - case sensitive. + Uniqueness is checked with the 'eq' operator so among other things it + is case sensitive. As a side effect the module does not allow undef as a value in the array. EXAMPLES + use Array::Unique; tie @a, 'Array::Unique'; - + @a = qw(a b c a d e f); push @a, qw(x b z); print "@a\n"; # a b c d e f x z DISCUSSION + When you are collecting a list of items and you want to make sure there is only one occurrence of each item, you have several option: 1) using an array and extracting the unique elements later - You might use a regular array to hold this unique set of values and - either remove duplicates on each update by that keeping the array - always unique or remove duplicates just before you want to use the - uniqueness feature of the array. In either case you might run a - function you call @a = unique_value(@a); - - The problem with this approach is that you have to implement the - unique_value function (see later) AND you have to make sure you - don't forget to call it. I would say don't rely on remembering this. - - There is good discussion about it in the 1st edition of the Perl - Cookbook of O'Reilly. I have copied the solutions here, you can see - further discussion in the book. - - Extracting Unique Elements from a List (Section 4.6 in the Perl - Cookbook 1st ed.) - - # Straightforward - - %seen = (); - @uniq = (); - foreach $item (@list) [ - unless ($seen{$item}) { - # if we get here we have not seen it before - $seen{$item} = 1; - push (@uniq, $item); - } - } - - # Faster - - %seen = (); - foreach $item (@list) { - push(@uniq, $item) unless $seen{$item}++; - } - - # Faster but different - - %seen; - foreach $item (@list) { - $seen{$item}++; - } - @uniq = keys %seen; - - # Faster and even more different - %seen; - @uniq = grep {! $seen{$_}++} @list; + + You might use a regular array to hold this unique set of values and + either remove duplicates on each update by that keeping the array + always unique or remove duplicates just before you want to use the + uniqueness feature of the array. In either case you might run a + function you call @a = unique_value(@a); + + The problem with this approach is that you have to implement the + unique_value function (see later) AND you have to make sure you don't + forget to call it. I would say don't rely on remembering this. + + There is good discussion about it in the 1st edition of the Perl + Cookbook of O'Reilly. I have copied the solutions here, you can see + further discussion in the book. + + Extracting Unique Elements from a List (Section 4.6 in the Perl + Cookbook 1st ed.) + + # Straightforward + + %seen = (); + @uniq = (); + foreach $item (@list) [ + unless ($seen{$item}) { + # if we get here we have not seen it before + $seen{$item} = 1; + push (@uniq, $item); + } + } + + # Faster + + %seen = (); + foreach $item (@list) { + push(@uniq, $item) unless $seen{$item}++; + } + + # Faster but different + + %seen; + foreach $item (@list) { + $seen{$item}++; + } + @uniq = keys %seen; + + # Faster and even more different + %seen; + @uniq = grep {! $seen{$_}++} @list; 2) using a hash - Some people use the keys of a hash to keep the items and put an - arbitrary value as the values of the hash: - To build such a list: + Some people use the keys of a hash to keep the items and put an + arbitrary value as the values of the hash: + + To build such a list: + + %unique = map { $_ => 1 } qw( one two one two three four! ); - %unique = map { $_ => 1 } qw( one two one two three four! ); + To print it: - To print it: + print join ", ", sort keys %unique; - print join ", ", sort keys %unique; + To add values to it: - To add values to it: + $unique{$_}=1 foreach qw( one after the nine oh nine ); - $unique{$_}=1 foreach qw( one after the nine oh nine ); + To remove values: - To remove values: + delete @unique{ qw(oh nine) }; - delete @unique{ qw(oh nine) }; + To check if a value is there: - To check if a value is there: + $unique{ $value }; # which is why I like to use "1" as my value - $unique{ $value }; # which is why I like to use "1" as my value + (thanks to Gaal Yahas for the above examples) - (thanks to Gaal Yahas for the above examples) + There are three drawbacks I see: - There are three drawbacks I see: + 1) You type more. - 1) You type more. - 2) Your reader might not understand at first why did you use hash - and what will be the values. - 3) You lose the order. + 2) Your reader might not understand at first why did you use hash and + what will be the values. - Usually non of them is critical but when I saw this the 10th time in - a code I had to understand with 0 documentation I got frustrated. + 3) You lose the order. + + Usually non of them is critical but when I saw this the 10th time in + a code I had to understand with 0 documentation I got frustrated. 3) using Array::Unique - So I decided to write this module because I got frustrated by my - lack of understanding what's going on in that code I mentioned. - In addition I thought it might be interesting to write this and then - benchmark it. + So I decided to write this module because I got frustrated by my lack + of understanding what's going on in that code I mentioned. + + In addition I thought it might be interesting to write this and then + benchmark it. - Additionally it is nice to have your name displayed in bright lights - all over CPAN ... or at least in a module. + Additionally it is nice to have your name displayed in bright lights + all over CPAN ... or at least in a module. - Array::Unique lets you tie an array to hmmm, itself (?) and makes - sure the values of the array are always unique. + Array::Unique lets you tie an array to hmmm, itself (?) and makes + sure the values of the array are always unique. - Since writing this I am not sure if I really recommend its usage. I - would say stick with the hash version and document that the variable - is aggregating a unique list of values. + Since writing this I am not sure if I really recommend its usage. I + would say stick with the hash version and document that the variable + is aggregating a unique list of values. 4) Using real SET - There are modules on CPAN that let you create and maintain SETs. I - have not checked any of those but I guess they just as much of an - overkill for this functionality as Unique::Array. + + There are modules on CPAN that let you create and maintain SETs. I + have not checked any of those but I guess they just as much of an + overkill for this functionality as Unique::Array. BUGS + use Array::Unique; tie @a, 'Array::Unique'; - + @c = @a = qw(a b c a d e f b); - + @c will contain the same as @a AND two undefs at the end because @c you get the same length as the right most list. TODO + Test: Change size of the array Elements with false values ('', '0', 0) @@ -177,9 +190,11 @@ Write even better implementations. AUTHOR + Gabor Szabo <ga...@pti.co.il> LICENSE + Copyright (C) 2002-2008 Gabor Szabo <ga...@pti.co.il> All rights reserved. http://www.pti.co.il/ @@ -189,6 +204,7 @@ No WARRANTY whatsoever. CREDITS + Thanks for suggestions and bug reports to Szabo Balazs (dLux) Shlomo Yona @@ -197,6 +213,7 @@ Werner Weichselberger VERSION + Version: 0.08 Date: 2008 June 04 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/README.md new/Array-Unique-0.09/README.md --- old/Array-Unique-0.08/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/Array-Unique-0.09/README.md 2023-05-29 19:28:42.000000000 +0200 @@ -0,0 +1,13 @@ +# Array::Unique Perl module + +## Release process + +* Update VERSION in module +* Update the Changes file + + perl Build.PL + perl Build + perl Build test + perl Build manifest + perl Build dist + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/benchmark.pl new/Array-Unique-0.09/benchmark.pl --- old/Array-Unique-0.08/benchmark.pl 1970-01-01 01:00:00.000000000 +0100 +++ new/Array-Unique-0.09/benchmark.pl 2023-05-29 19:28:42.000000000 +0200 @@ -0,0 +1,48 @@ +#!/usr/bin/perl +use strict; +use warnings; +use Benchmark qw(cmpthese timethese); + +my @a = 'aaaa' .. 'bbbb'; # 18,280 words; +my $value = "bbbb"; + + + +#print scalar @a; +#exit; + +sub ina { + my $value = shift; + #my $ar = shift; + + return scalar grep {$value eq $_} @_; +} + +sub ina2($\@) { + my $value = shift; + my $ar = shift; + + foreach my $v (@$ar) { + return 1 if ($v eq $value); + } + return 0; +} + + +print ina($value, @a),"\n"; +print ina2($value, @a),"\n"; +print scalar grep({$value eq $_} @a), "\n"; +foreach my $v (@a) { + if ($v eq $value) { + print "Ok\n"; + last; + } +} + +timethese(1000000, { + ina => q(ina($value, @a)), + ina2 => q(ina($value, @a)), + ina3 => q(scalar grep {$value eq $_} @a), + ina4 => q|foreach my $v (@a) { last if ($v eq $value)}|, +}); + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/dev.pl new/Array-Unique-0.09/dev.pl --- old/Array-Unique-0.08/dev.pl 1970-01-01 01:00:00.000000000 +0100 +++ new/Array-Unique-0.09/dev.pl 2023-05-29 19:28:42.000000000 +0200 @@ -0,0 +1,88 @@ + +use strict; +use warnings; + + +use Array::Unique 0.04; + +print "----------------------------------\n"; +my @a; +my $o; + +#$o = tie @a, "Array::Unique"; +$o = tie @a, "Array::Unique", 'Std'; +#$o = tie @a, "Array::Unique", 'Quick'; +#$o = tie @a, "Array::Unique", 'IxHash'; +#require Devel::TraceMethods; +#import Devel::TraceMethods qw(Array::Unique Array::Unique::IxHash); +#import Devel::TraceMethods qw(Array::Unique Array::Unique::Std); +#print $o; +die "Could not initialize" unless (defined $o); +# --------------------------------------------------- +# create an array where there were dupplicates +# --------------------------------------------------- +@a=(); +@a=qw(a b a); +#@a=qw(x y z q p r s t w); +print "@a\n"; +#my @b = splice(@a, -5, 2, qw(z a x)); +#my @b = splice(@a, 4, 2, qw(z a x)); +#print "@b\n"; +#print "@a\n"; +#print $a[1], "\n"; +#print $a[-1], "\n"; +#print 'top index: ', $#a, "\n"; +#print 'count: ', scalar @a, "\n"; +#print 'content: ', @a, "\n"; +#print 'content: ', @a, "\n"; +#print $a[1],"\n"; + +#$#a=0; +#print "@a\n"; + +#print "$a[0]\n"; +#print "$a[1]\n"; + +#@a=qw(a b c a d a b q a); +#ok("@a" eq "a b c d q"); +#print "DEBUG: '@a'\n"; + +#print "z: ", $o->exists('z'), "\n"; +#print "b: ", $o->exists('b'), "\n"; + + +#@a[7, 15, 28] = qw(p q r); +#print "xDEBUG: '@a'\n"; + +__END__ +use lib qw(blib/lib); +use Array::Unique; + +my @a; +my $o = tie @a, "Array::Unique"; + + +@a = qw(a c d o p a); + +foreach my $v (@a) { + print $v; +} + + +__END__ + + + +@a = qw(b c d); +$a[7]='z'; +#$a[3]=x; +#undef $a[3]; +print "@a\n"; +print exists $a[2], "2\n"; +print defined $a[2], "2\n"; +print exists $a[3], "3\n"; +print defined $a[3], "3\n"; +print "@a\n"; + + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/lib/Array/Unique/Hash.pm new/Array-Unique-0.09/lib/Array/Unique/Hash.pm --- old/Array-Unique-0.08/lib/Array/Unique/Hash.pm 1970-01-01 01:00:00.000000000 +0100 +++ new/Array-Unique-0.09/lib/Array/Unique/Hash.pm 2023-05-29 19:28:42.000000000 +0200 @@ -0,0 +1,131 @@ +package Array::Unique::Hash; + +use strict; +use warnings; + +our $VERSION = '0.09'; + +sub new { + TIEARRAY(@_); +} + +sub TIEARRAY { + my $class = shift; + my $self = { + array => [], + hash => {}, + }; + bless $self, $class; +} + + +sub CLEAR { + my $self = shift; + $self->{array} = []; + $self->{hash} = {}; +} + +sub EXTEND { + my $self = shift; + #? +} + +sub STORE { + my ($self, $index, $value) = @_; + $self->SPLICE($index, 1, $value); +} + + + +sub FETCHSIZE { + my $self = shift; + return scalar @{$self->{array}}; +} + +sub FETCH { + my ($self, $index) = @_; + ${$self->{array}}[$index]; +} + + +sub STORESIZE { + my $self = shift; + my $size = shift; + + # We cannot enlarge the array as the values would be undef + + # But we can make it smaller +# if ($self->FETCHSIZE > $size) { +# $self->{->Splice($size); +# } + + $#{$self->{array}} = $size; + return $size; +} + +#sub EXISTS { exists $_[0]->[$_[1]] } +#sub DELETE { delete $_[0]->[$_[1]] } +#sub DESTROY + +sub SPLICE { + my $self = shift; + my $offset = shift; + my $length = shift; + + # reset length value to positive (this is done by the normal splicetoo) + if ($length < 0) { + #$length = @{$self->{array}} + $length; + $length = $self->FETCHSIZE + $length; + } + + # reset offset to positive (this is done by the normal splice too) + if ($offset < 0) { + $offset += $self->FETCHSIZE; + } + +# if ($offset > $self->FETCHSIZE) { +# $offset = $self->FETCHSIZE; +# } + +# my @s = @{$self->{array}}[$offset..$offset+$length]; # the old values to be returned + my @original = splice @{$self->{array}}, $offset, $length, @_; + + return @original; +} + + + +sub PUSH { + my $self = shift; + + $self->SPLICE($self->FETCHSIZE, 0, @_); +# while (my $value = shift) { +# $self->STORE($self->FETCHSIZE+1, $value); +# } + return $self->FETCHSIZE; +} + +sub POP { + my $self = shift; + $self->SPLICE(-1); +} + +sub SHIFT { + my $self = shift; + + #($self->{array})[0]; + $self->SPLICE(0,1); +} + +sub UNSHIFT { + my $self = shift; + $self->SPLICE(0,0,@_); +} + +1; +__END__ +=pod + + See Array::Unique for documentation + +=cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/lib/Array/Unique/IxHash.pm new/Array-Unique-0.09/lib/Array/Unique/IxHash.pm --- old/Array-Unique-0.08/lib/Array/Unique/IxHash.pm 1970-01-01 01:00:00.000000000 +0100 +++ new/Array-Unique-0.09/lib/Array/Unique/IxHash.pm 2023-05-29 19:28:42.000000000 +0200 @@ -0,0 +1,141 @@ +package Array::Unique::IxHash; +# This implementation uses Tie::IxHash + +use strict; +use warnings; + +our $VERSION = '0.09'; + +use Tie::IxHash; + +sub _init { + my $self = shift; + + $self->[0] = Tie::IxHash->new(); +} + +sub CLEAR { + my $self = shift; + $self->[0]->Splice(0); +} + +sub EXTEND { + my $self = shift; + #? +} + +sub STORE { + my ($self, $index, $value) = @_; + $self->SPLICE($index, 1, $value); +} + +sub PUSH { + my $self = shift; + + while (my $value = shift) { + $self->[0]->Push($value => 1); + } +} + +sub FETCHSIZE { + my $self = shift; + return $self->[0]->Length; +} + +sub FETCH { + my ($self, $index) = @_; + $self->[0]->Keys($index); +} + + +sub STORESIZE { + my $self = shift; + my $size = shift; + + # We cannot enlarge the array as the values would be undef + + # But we can make it smaller + if ($self->FETCHSIZE > $size) { + $self->[0]->Splice($size); + } +} + +#sub EXISTS { exists $_[0]->[$_[1]] } +#sub DELETE { delete $_[0]->[$_[1]] } +#sub DESTROY + +# insert one value at the given position +# but if the value already existed then set its +# postion to the lower place between its original position +# and the new one. +sub insert { + my ($self, $index, $value) = @_; + + #$self->[0]->Replace($index, 1, $value); + # Replace does not keep the order when storing an existing value + # in an index higher than its original index. + + if ($self->FETCHSIZE < $index+1) { + $self->[0]->Push($value => 1); + } else { + my $oldindex = $self->[0]->Indices($value); + if (not defined $oldindex) { + $self->[0]->Splice($index, 0 , $value); + } else { + if ($oldindex == $index) { + $self->[0]->Splice($index, 1, $value => 1); + } elsif ($oldindex > $index) { + $self->[0]->Splice($oldindex, 1); + $self->[0]->Splice($index, 0, $value); + } else { + # nothing to do + } + } + } + +} + +sub SPLICE { + my $self = shift; + my $offset = shift; + my $length = shift; + + if ($offset < 0) { + $offset += $self->FETCHSIZE; + } + my @s = $self->[0]->Splice($offset, $length); + + foreach my $v (reverse @_) { + $self->insert($offset, $v); + } + + my @q; + for my $i (1..scalar(@s)/2) { + push @q, $s[2*$i-2]; + } + return @q; +} + +sub UNSHIFT { + my $self = shift; + $self->SPLICE(0,0,@_); +} + +sub SHIFT { + my $self = shift; + + ($self->[0]->Shift)[0]; +} + +sub POP { + my $self = shift; + ($self->[0]->Pop)[0]; +} + +1; +__END__ +=pod + + See Array::Unique for documentation + +=cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/lib/Array/Unique/Quick.pm new/Array-Unique-0.09/lib/Array/Unique/Quick.pm --- old/Array-Unique-0.08/lib/Array/Unique/Quick.pm 1970-01-01 01:00:00.000000000 +0100 +++ new/Array-Unique-0.09/lib/Array/Unique/Quick.pm 2023-05-29 19:28:42.000000000 +0200 @@ -0,0 +1,99 @@ +package Array::Unique::Quick; + +use strict; +use warnings; +use Carp; + +our $VERSION = '0.09'; + +sub _init { + my $self = shift; + +# $self->[0] = {}; +} + +sub noimp { + carp "Method not implemented\n"; +} + +sub CLEAR { + my $self = shift; + %$self = (); +} + +sub EXTEND { + my $self = shift; + #? +} + +sub STORE { + my $self = shift; + my $index = shift; + my $value = shift; + + $self->{$value}=1; +} + +sub PUSH { + my $self = shift; + + foreach (@_) { + $self->{$_}=1; + } +} + +sub FETCHSIZE { + my $self = shift; + return scalar keys %$self; +} + +sub FETCH { + my ($self, $index) = @_; + return ((keys (%$self))[$index]); +} + + +sub STORESIZE { + my $self = shift; + my $size = shift; + + # We cannot enlarge the array as the values would be undef + + # But we can make it smaller + if ($self->FETCHSIZE > $size) { + $self->[0]->Splice($size); + } +} + + +sub SPLICE { + my $self = shift; + $self->noimp; +} + +sub UNSHIFT { + my $self = shift; + $self->noimp; +# $self->SPLICE(0,0,@_); +} + +sub SHIFT { + my $self = shift; + $self->noimp; + +# ($self->[0]->Shift)[0]; +} + +sub POP { + my $self = shift; + $self->noimp; +# ($self->[0]->Pop)[0]; +} + +1; +__END__ +=pod + + See Array::Unique for documentation + +=cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/lib/Array/Unique/Std.pm new/Array-Unique-0.09/lib/Array/Unique/Std.pm --- old/Array-Unique-0.08/lib/Array/Unique/Std.pm 1970-01-01 01:00:00.000000000 +0100 +++ new/Array-Unique-0.09/lib/Array/Unique/Std.pm 2023-05-29 19:28:42.000000000 +0200 @@ -0,0 +1,102 @@ +package Array::Unique::Std; + +use strict; +use warnings; + +our $VERSION = '0.09'; + +use Tie::Array; +#use base qw(Tie::StdArray); +our @ISA; +push @ISA, qw(Tie::StdArray); + +sub _init { + my $self = shift; +} + +sub clean { + my $self = shift; + +# print "DEBUG: '@$self'\n"; + my @temp; + foreach my $v (@$self) { + next unless (defined $v); + unless (grep {$v eq $_} @temp) { + push @temp, $v; + } + } + @$self = @temp; + +} +sub STORESIZE { + my $self = shift; + my $size = shift; + + if ($self->FETCHSIZE > $size) { + $self->SUPER::STORESIZE($size); + } +} + +sub find { + my $self = shift; + my $value = shift; + my @rep = grep {$value eq $self->FETCH($_)} (0 .. $self->FETCHSIZE-1); + if (@rep) { + return shift @rep; + } else { + return; + } +} + +sub STORE { + my $self = shift; + my $index = shift; + my $value = shift; +# print "STORE PARAM: @_\n"; + + my $existing = $self->find($value); # O(n) + if (defined $existing) { +# if ($existing <= $index) { + ## nothing to do +# } else { + $self->SUPER::STORE($index, $value); # value in earlier location + $self->SPLICE($existing, 1); +# } + } else { + $self->SUPER::STORE($index, $value); # new value + } + $self->clean; + +} + +sub PUSH { + my $self = shift; + + $self->SUPER::PUSH(@_); + $self->clean; +} + + +sub UNSHIFT { + my $self = shift; + + $self->SUPER::UNSHIFT(@_); + $self->clean; + +} + +sub SPLICE { + my $self = shift; + + my @splice = $self->SUPER::SPLICE(@_); + $self->clean; + return @splice; +} + +1; +__END__ +=pod + +See documentation in Array::Unique + +=cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Array-Unique-0.08/lib/Array/Unique.pm new/Array-Unique-0.09/lib/Array/Unique.pm --- old/Array-Unique-0.08/lib/Array/Unique.pm 2008-06-04 06:48:22.000000000 +0200 +++ new/Array-Unique-0.09/lib/Array/Unique.pm 2023-05-29 19:28:42.000000000 +0200 @@ -5,7 +5,7 @@ use warnings; use Carp; -our $VERSION = '0.08'; +our $VERSION = '0.09'; # Strips out any duplicate values (leaves the first occurrence # of every duplicated value and drops the later occurrences).