Acme-Bitfield

 view release on metacpan or  search on metacpan

CODE_OF_CONDUCT.md  view on Meta::CPAN

posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
https://github.com/sanko/Net-BitTorrent.pm/discussions.
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed

CONTRIBUTING.md  view on Meta::CPAN


    ```bash
    # For a new feature:
    git checkout -b feature/add-riscv-support
    # For a bug fix:
    git checkout -b fix/struct-classification-bug
    ```

4.  **Make Your Changes**: Write your code. Please adhere to the existing coding style and add comments to new or complex logic.
5.  **Test Your Changes**: A pull request is far more likely to be accepted if it includes tests. If you add new functionality, please add a corresponding test case.
6.  **Update the Changelog**: Add an entry to the `[Unreleased]` section of `CHANGELOG.md` describing your change.
7.  **Submit a Pull Request**: Push your branch to your fork and open a pull request against the `main` branch of the original repository. Please provide a clear description of your changes and link to the relevant issue (e.g., `Fixes #123`).

Changes.md  view on Meta::CPAN


All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v1.1.0] - 2026-02-02

### Added
- Added `is_full()` and `is_empty()` methods for quick status checks.
- Added bitwise set operations: `union( ... )`, `intersection( ... )`, and `difference( ... )`.

## [v1.0.0] - 2026-01-29

### Changed
- It actually exists.

[Unreleased]: https://github.com/sanko/Acme-Bitfield.pm/compare/v1.1.0...HEAD
[v1.1.0]: https://github.com/sanko/Acme-Bitfield.pm/compare/v1.0.0...v1.1.0
[v1.0.0]: https://github.com/sanko/Acme-Bitfield.pm/releases/tag/v1.0.0

README.md  view on Meta::CPAN

Returns the index of the first bit set to 0, or `undef` if all bits are set.

## `inverse( )`

Returns a new bitfield object with all bits within the `size` inverted. Bit 0 becomes 1, and 1 becomes 0.

## `union( $other )`

Returns a new bitfield object representing the bitwise OR of this bitfield and `$other`.

## `intersection( $other )`

Returns a new bitfield object representing the bitwise AND of this bitfield and `$other`.

## `difference( $other )`

Returns a new bitfield object representing the bits set in this bitfield but NOT in `$other` (bitwise AND NOT).

# AUTHOR

Sanko Robinson <sanko@cpan.org>

SECURITY.md  view on Meta::CPAN

# Security Policy

Until I have the version 1.0.0 release, I'll support only the last two minor versions with security updates.

## Supported Versions

| Version    | Supported          |
| ---------- | ------------------ |
| v1.0.x     | :white_check_mark: |
| < v1.0.0   | :x:                |

# Reporting a Vulnerability

If you have any issue regarding security, please disclose the information responsibly by sending a report to the project's security advisory page and *not* at the public issue tracker or via email.

# Vulnerability Disclosure Policy

Maintaining the security of our open-source software is paramount. This policy outlines a responsible approach to addressing vulnerabilities, balancing transparency with the need to protect users.

- Security vulnerabilities identified in the project will be assigned a unique identifier and (if applicable) a Common Vulnerabilities and Exposures (CVE) identifier.

- The project's Maintainers will be responsible for addressing the vulnerability through a standard pull request, backporting the fix to immediate prior minor release branch, and including the fix in the next stable release.

- Release notes for the patched version will include the assigned identifier and, if applicable, the CVE identifier for the vulnerability.

- A grace period will be provided for Maintainers to update the vulerable minor version and remove vulerable releases from PAUSE (nothing can be done about backpan).

  This period will be one month for non-critical vulnerabilities and three months for critical vulnerabilities.

lib/Acme/Bitfield.pm  view on Meta::CPAN

    method is_empty () {
        return $data =~ tr/\0//c ? 0 : 1;
    }

    method union ($other) {
        my $new = __CLASS__->new( size => $size );
        $new->set_data( $data|.$other->data );
        return $new;
    }

    method intersection ($other) {
        my $new = __CLASS__->new( size => $size );
        $new->set_data( $data&.$other->data );
        return $new;
    }

    method difference ($other) {

        # Bits set in self but NOT in other
        my $new = __CLASS__->new( size => $size );
        $new->set_data( $data&.~.$other->data );

lib/Acme/Bitfield.pod  view on Meta::CPAN

Returns the index of the first bit set to 0, or C<undef> if all bits are set.

=head2 C<inverse( )>

Returns a new bitfield object with all bits within the C<size> inverted. Bit 0 becomes 1, and 1 becomes 0.

=head2 C<union( $other )>

Returns a new bitfield object representing the bitwise OR of this bitfield and C<$other>.

=head2 C<intersection( $other )>

Returns a new bitfield object representing the bitwise AND of this bitfield and C<$other>.

=head2 C<difference( $other )>

Returns a new bitfield object representing the bits set in this bitfield but NOT in C<$other> (bitwise AND NOT).

=head1 AUTHOR

Sanko Robinson E<lt>sanko@cpan.orgE<gt>

t/basics.t  view on Meta::CPAN

subtest 'Bitwise Operations' => sub {
    my $bf1 = Acme::Bitfield->new( size => 10 );
    my $bf2 = Acme::Bitfield->new( size => 10 );
    $bf1->set($_) for ( 0, 1, 2 );
    $bf2->set($_) for ( 2, 3, 4 );
    subtest 'Union' => sub {
        my $union = $bf1->union($bf2);
        is( $union->count, 5, 'Union count is 5' );
        ok( $union->get($_), "Bit $_ set in union" ) for ( 0, 1, 2, 3, 4 );
    };
    subtest 'Intersection' => sub {
        my $inter = $bf1->intersection($bf2);
        is( $inter->count, 1, 'Intersection count is 1' );
        ok( $inter->get(2),  'Bit 2 set in intersection' );
        ok( !$inter->get(0), 'Bit 0 NOT set in intersection' );
    };
    subtest 'Difference' => sub {
        my $diff = $bf1->difference($bf2);
        is( $diff->count, 2, 'Difference count is 2' );
        ok( $diff->get(0),  'Bit 0 set in difference' );
        ok( $diff->get(1),  'Bit 1 set in difference' );
        ok( !$diff->get(2), 'Bit 2 NOT set in difference' );
    };
};
subtest 'Status Checks' => sub {



( run in 1.324 second using v1.01-cache-2.11-cpan-39bf76dae61 )