Package cc.redberry.core.utils

Examples of cc.redberry.core.utils.BitArray


     * @param permutation permutation written in one-line notation
     * @return an array of cycles lengths
     */
    public static int[] lengthsOfCycles(final short[] permutation) {
        IntArrayList sizes = new IntArrayList();
        BitArray seen = new BitArray(permutation.length);
        int counter = 0;
        while (counter < permutation.length) {
            int start = seen.nextZeroBit(0);
            if (permutation[start] == start) {
                ++counter;
                seen.set(start);
                continue;
            }
            int size = 0;
            while (!seen.get(start)) {
                seen.set(start);
                ++counter;
                ++size;
                start = permutation[start];
            }
            sizes.add(size);
View Full Code Here


     * @param permutation permutation written in one-line notation
     * @return an array of cycles lengths
     */
    public static int[] lengthsOfCycles(final byte[] permutation) {
        IntArrayList sizes = new IntArrayList();
        BitArray seen = new BitArray(permutation.length);
        int counter = 0;
        while (counter < permutation.length) {
            int start = seen.nextZeroBit(0);
            if (permutation[start] == start) {
                ++counter;
                seen.set(start);
                continue;
            }
            int size = 0;
            while (!seen.get(start)) {
                seen.set(start);
                ++counter;
                ++size;
                start = permutation[start];
            }
            sizes.add(size);
View Full Code Here

            int omittedIndicesCount = structure.getTypeData(omittedIndexType.getType()).length;
            if ((omittedIndicesCount % 2) == 1)
                throw new IllegalArgumentException("The number of omitted indices for metric types should be even.");
            omittedIndicesCount /= 2;

            BitArray omittedIndices = structure.getTypeData(omittedIndexType.getType()).states;

            for (int i = 0, size = omittedIndices.size(); i < size; ++i) {
                if (i < omittedIndicesCount && !omittedIndices.get(i))
                    throw new IllegalArgumentException("Inconsistent states signature for metric type.");
                if (i >= omittedIndicesCount && omittedIndices.get(i))
                    throw new IllegalArgumentException("Inconsistent states signature for metric type.");
            }
        }
        mappedRules = null;
        InsertionRule rule = initialRules.get(originalStructureAndName);
View Full Code Here

            //this.insertionRule = insertionRule;
            StructureOfIndices originalStructure = insertionRule.originalStructureAndName.getStructure()[0];
            StructureOfIndices currentStructure = node.getIndicesTypeStructureAndName().getStructure()[0];
            for (IndexType type : insertionRule.indicesAllowedToOmit)
                if (currentStructure.getStates(type).size() == 0) {
                    BitArray originalStates = originalStructure.getStates(type);
                    if (originalStates != null) {
                        outerIndices.upper[type.getType()] = originalStates.bitCount();
                        outerIndices.lower[type.getType()] = originalStates.size() - outerIndices.upper[type.getType()];
                    } else {
                        outerIndices.upper[type.getType()] = outerIndices.lower[type.getType()]
                                = originalStructure.typeCount(type.getType()) / 2;
                    }
                } else if (currentStructure.typeCount(type.getType()) !=
View Full Code Here

    }

    @Override
    public int[][] cycles() {
        ArrayList<int[]> cycles = new ArrayList<>();
        BitArray seen = new BitArray(internalDegree());
        int counter = 0;
        while (counter < internalDegree()) {
            int start = seen.nextZeroBit(0);
            if (newIndexOf(start) == start) {
                ++counter;
                seen.set(start);
                continue;
            }
            IntArrayList cycle = new IntArrayList();
            while (!seen.get(start)) {
                seen.set(start);
                ++counter;
                cycle.add(start);
                start = newIndexOf(start);
            }
            cycles.add(cycle.toArray());
View Full Code Here

TOP

Related Classes of cc.redberry.core.utils.BitArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.