Skip to content
Snippets Groups Projects
Select Git revision
  • v2.25.12
  • main default
  • pu/openpgp-naming
  • pu/gnupg-cleanup
  • pu/perl-reduce-deps
  • pu/workflow
  • pu/debdiff-no-check
  • v2.25.14
  • v2.25.13
  • v2.25.11
  • v2.25.10
  • v2.25.9
  • v2.25.8
  • v2.25.7
  • v2.25.6
  • v2.25.5
  • v2.25.4
  • v2.25.3
  • v2.25.2
  • v2.25.1
  • v2.24.10
  • v2.24.9
  • v2.24.8
  • v2.24.7
  • v2.24.6
  • v2.24.5
26 results

Set.pm

  • Forked from Debian / devscripts
    Source project has a limited visibility.
    Set.pm 2.88 KiB
    # Copyright Bill Allombert <ballombe@debian.org> 2001.
    # Modifications copyright 2002 Julian Gilbey <jdg@debian.org>
    
    # This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 2 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program. If not, see <https://www.gnu.org/licenses/>.
    
    package Devscripts::Set;
    
    use strict;
    
    BEGIN {
        use Exporter ();
        use vars     qw(@EXPORT @ISA %EXPORT_TAGS);
        @EXPORT      = qw(SetMinus SetInter SetUnion);
        @ISA         = qw(Exporter);
        %EXPORT_TAGS = ();
    }
    
    # Several routines to work with arrays whose elements are unique
    # (here called sets)
    
    =head1 NAME
    
    Devscripts::Set - Functions for handling sets.
    
    =head1 SYNOPSIS
    
    use Devscripts::Set;
    
    @set=ListToSet(@list);
    
    @setdiff=SetMinus(\@set1,\@set2);
    
    @setinter=SetInter(\@set1,\@set2);
    
    @setunion=SetUnion(\@set1,\@set2);
    
    =head1 DESCRIPTION
    
    ListToSet: Make a set (array with duplicates removed) from a list of
    items given by an array.
    
    SetMinus, SetInter, SetUnion: Compute the set theoretic difference,
    intersection, union of two sets given as arrays.
    
    =cut
    
    # Transforms a list to a set, removing duplicates
    # input:  list
    # output: set
    
    sub ListToSet (@) {
        my %items;
    
        grep $items{$_}++, @_;
    
        return keys %items;
    }
    
    # Compute the set-theoretic difference of two sets.