#!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd pp /; my @ints = qw/ 0 0 0 1 1 2 9 11 11 20 22 22 55 /; #~ my $power = 8; my $repeat = 0; #~ my $power = 2; my $repeat = 14; #~ my $power = 1; my $repeat = 28; my $power = 3; my $repeat = 7; #~ my $power = 28; my $repeat = 8; ## (chr(0)x2**28)x8 my $max = 2**$power; my $maxminone = $max-1; my @seen_vecs = ( chr(0) x $max ) x $repeat;; @seen_vecs = '' unless@seen_vecs ; dd\@seen_vecs; print "\n(2**$power=($max)*8=(l@{[$max*8]}))x[$repeat]\n"; print "max bit \@v[$repeat][@{[$max*8]}]\n\n"; my @uniq ; for my $int( @ints ){ my $index = $int >> $power; my $offset = $int & $maxminone ; #~ my $vec = \vec( $seen_vecs[ $int >> $power ], $int & $maxminone , 1);; my $vec = \vec( $seen_vecs[ $index ], $offset, 1);; next if $$vec ; ## skip if seen ## $seen...[$index]->get( $offset ); push @uniq, $int; $$vec=1; ## mark as seen ## $seen...[$index]->set( $offset ); printf "%3u@[%2u][%2u]= %s\n", $int , $index, $offset,unpack('b*', $seen_vecs[ $index ]), ; printf " %s\n", (' ' x $offset ).'^'.$int; } dd({ints=>\@ints,uniq=>\@uniq,seen=>\@seen_vecs}); __END__