All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.maven.mercury.metadata.sat.SatHelper Maven / Gradle / Ivy

The newest version!
/**
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */
package org.apache.maven.mercury.metadata.sat;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

import org.apache.maven.mercury.artifact.ArtifactMetadata;
import org.sat4j.core.ReadOnlyVec;
import org.sat4j.core.ReadOnlyVecInt;
import org.sat4j.core.Vec;
import org.sat4j.core.VecInt;
import org.sat4j.specs.IConstr;
import org.sat4j.specs.IVec;
import org.sat4j.specs.IVecInt;

/**
 * @author Oleg Gusakov
 */
public class SatHelper
{
  //-----------------------------------------------------------------------
  public static final List createList( String... uris )
  {
    List aml = new ArrayList( uris.length );
    for( String uri : uris )
    {
      aml.add( new ArtifactMetadata(uri) );
    }
    return aml;
  }
  //-----------------------------------------------------------------------
  public static final IVecInt getSmallOnes( int... ints )
  {
    VecInt res = new VecInt( ints );
    return new ReadOnlyVecInt(res);
  }
  //-----------------------------------------------------------------------
  public static final IVecInt getSmallOnes( int first, int second )
  {
    return getSmallOnes( new int [] {first, second} );
  }
  //-----------------------------------------------------------------------
  public static int [] toIntArray( int first, int... ints )
  {
    int [] lits = new int[ ints.length+1 ];
    lits[0] = first;
    int ptr = 1;

    for( int i : ints )
      lits[ptr++] = i;
    
    return lits;
  }
  //-----------------------------------------------------------------------
  private static final IVec toVec( BigInteger... bis  )
  {
    return new ReadOnlyVec( new Vec( bis ) );
  }
  //-----------------------------------------------------------------------
  public static final IVec getBigOnes( int... ones )
  {
    BigInteger [] res = new BigInteger[ ones.length ];
    
    for( int i=0; i getBigOnes( int nOnes, boolean negate )
  {
    BigInteger [] res = new BigInteger[ nOnes ];
    BigInteger bi = negate ? BigInteger.ONE.negate() : BigInteger.ONE;
    
    for( int i=0; i getBigOnes( int first, int nOnes, boolean negateOnes )
  {
    int len = nOnes + 1;

    BigInteger [] res = new BigInteger[ len ];
    res[ 0 ] = BigInteger.valueOf(first);
    
    BigInteger bi = negateOnes ? BigInteger.ONE.negate() : BigInteger.ONE;
    
    for( int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy