< Summary

Information
Class: LeetCode.Algorithms.DesignHashSet.DesignHashSetBitArray
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\DesignHashSet\DesignHashSetBitArray.cs
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 51
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
Add(...)100%11100%
Remove(...)100%11100%
Contains(...)100%11100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Algorithms\DesignHashSet\DesignHashSetBitArray.cs

#LineLine coverage
 1// --------------------------------------------------------------------------------
 2// Copyright (C) 2025 Eugene Eremeev (also known as Yevhenii Yeriemeieiv).
 3// All Rights Reserved.
 4// --------------------------------------------------------------------------------
 5// This software is the confidential and proprietary information of Eugene Eremeev
 6// (also known as Yevhenii Yeriemeieiv) ("Confidential Information"). You shall not
 7// disclose such Confidential Information and shall use it only in accordance with
 8// the terms of the license agreement you entered into with Eugene Eremeev (also
 9// known as Yevhenii Yeriemeieiv).
 10// --------------------------------------------------------------------------------
 11
 12using System.Collections;
 13
 14namespace LeetCode.Algorithms.DesignHashSet;
 15
 16/// <inheritdoc />
 17public class DesignHashSetBitArray : DesignHashSetBase
 18{
 119    private readonly BitArray _items = new(ItemsCount);
 20
 21    /// <summary>
 22    ///     Time complexity - O(1)
 23    ///     Space complexity - O(1)
 24    /// </summary>
 25    /// <param name="key"></param>
 26    public override void Add(int key)
 327    {
 328        _items[key] = true;
 329    }
 30
 31    /// <summary>
 32    ///     Time complexity - O(1)
 33    ///     Space complexity - O(1)
 34    /// </summary>
 35    /// <param name="key"></param>
 36    public override void Remove(int key)
 137    {
 138        _items[key] = false;
 139    }
 40
 41    /// <summary>
 42    ///     Time complexity - O(1)
 43    ///     Space complexity - O(1)
 44    /// </summary>
 45    /// <param name="key"></param>
 46    /// <returns></returns>
 47    public override bool Contains(int key)
 448    {
 449        return _items[key];
 450    }
 51}