Java BigInteger Calculate removeDuplicates(final BigInteger... values)

Here you can find the source of removeDuplicates(final BigInteger... values)

Description

Removes duplicate values from a BigInteger array

License

Open Source License

Parameter

Parameter Description
values An array of BigInteger values

Exception

Parameter Description
IllegalArgumentException if values is null

Return

the same array of BigInteger values without duplicates

Declaration

public static BigInteger[] removeDuplicates(final BigInteger... values) 

Method Source Code


//package com.java2s;
/*/*ww w. j  a  v  a  2 s  .c o m*/
 * UniCrypt
 *
 *  UniCrypt(tm) : Cryptographical framework allowing the implementation of cryptographic protocols e.g. e-voting
 *  Copyright (C) 2014 Bern University of Applied Sciences (BFH), Research Institute for
 *  Security in the Information Society (RISIS), E-Voting Group (EVG)
 *  Quellgasse 21, CH-2501 Biel, Switzerland
 *
 *  Licensed under Dual License consisting of:
 *  1. GNU Affero General Public License (AGPL) v3
 *  and
 *  2. Commercial license
 *
 *
 *  1. This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 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 Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 *  2. Licensees holding valid commercial licenses for UniCrypt may use this file in
 *   accordance with the commercial license agreement provided with the
 *   Software or, alternatively, in accordance with the terms contained in
 *   a written agreement between you and Bern University of Applied Sciences (BFH), Research Institute for
 *   Security in the Information Society (RISIS), E-Voting Group (EVG)
 *   Quellgasse 21, CH-2501 Biel, Switzerland.
 *
 *
 *   For further information contact <e-mail: unicrypt@bfh.ch>
 *
 *
 * Redistributions of files must retain the above copyright notice.
 */

import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashSet;

public class Main {
    /**
     * Removes duplicate values from a BigInteger array
     * <p>
     * @param values An array of BigInteger values
     * @return the same array of BigInteger values without duplicates
     * @throws IllegalArgumentException if {@literal values} is {@literal null}
     */
    public static BigInteger[] removeDuplicates(final BigInteger... values) {
        if (values == null) {
            throw new IllegalArgumentException();
        }
        final HashSet<BigInteger> hashSet = new HashSet<BigInteger>(Arrays.asList(values));
        return hashSet.toArray(new BigInteger[hashSet.size()]);
    }
}

Related

  1. parseBigInteger(String s, BigInteger defaultValue)
  2. parseBinaryBigInteger(final byte[] buffer, final int offset, final int length, final boolean negative)
  3. parseScaledNonNegativeBigInteger(String str)
  4. product(final BigInteger min, final BigInteger max)
  5. randomFromZn(BigInteger n, Random rand)
  6. renderBigInteger(final BigInteger bint)
  7. retrieveBigInteger(final byte[] buf, final int offset)
  8. rightshift(byte b1, BigInteger b2)
  9. saveKey(File destDir, String fileName, BigInteger modulus, BigInteger publicExponent)