Java Code Examples for com.helger.commons.CGlobal#ILLEGAL_ULONG

The following examples show how to use com.helger.commons.CGlobal#ILLEGAL_ULONG . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CombinationGenerator.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
/**
 * Ctor
 *
 * @param aElements
 *        the elements to fill into the slots for creating all combinations
 *        (must not be empty!)
 * @param nSlotCount
 *        the number of slots to use (must not be greater than the element
 *        count!)
 */
public CombinationGenerator (@Nonnull @Nonempty final ICommonsList <DATATYPE> aElements,
                             @Nonnegative final int nSlotCount)
{
  ValueEnforcer.notEmpty (aElements, "Elements");
  ValueEnforcer.isBetweenInclusive (nSlotCount, "SlotCount", 0, aElements.size ());

  m_aElements = GenericReflection.uncheckedCast (aElements.toArray ());
  m_aIndexResult = new int [nSlotCount];
  final BigInteger aElementFactorial = FactorialHelper.getAnyFactorialLinear (m_aElements.length);
  final BigInteger aSlotFactorial = FactorialHelper.getAnyFactorialLinear (nSlotCount);
  final BigInteger aOverflowFactorial = FactorialHelper.getAnyFactorialLinear (m_aElements.length - nSlotCount);
  m_aTotalCombinations = aElementFactorial.divide (aSlotFactorial.multiply (aOverflowFactorial));
  // Can we use the fallback to long? Is much faster than using BigInteger
  m_bUseLong = m_aTotalCombinations.compareTo (CGlobal.BIGINT_MAX_LONG) < 0;
  m_nTotalCombinations = m_bUseLong ? m_aTotalCombinations.longValue () : CGlobal.ILLEGAL_ULONG;
  reset ();
}
 
Example 2
Source File: AbstractStatisticsHandlerNumeric.java    From ph-commons with Apache License 2.0 6 votes vote down vote up
protected final void addValue (final long nValue)
{
  // Better performance when done manually
  m_aRWLock.writeLock ().lock ();
  try
  {
    m_nInvocationCount++;
    if (m_nMin == CGlobal.ILLEGAL_ULONG || nValue < m_nMin)
      m_nMin = nValue;
    if (m_nMax == CGlobal.ILLEGAL_ULONG || nValue > m_nMax)
      m_nMax = nValue;
    m_aSum = m_aSum.add (BigInteger.valueOf (nValue));
  }
  finally
  {
    m_aRWLock.writeLock ().unlock ();
  }
}
 
Example 3
Source File: PDTXMLConverter.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Get the passed {@link XMLGregorianCalendar} as milliseconds.
 *
 * @param aCal
 *        The source {@link XMLGregorianCalendar}. May be <code>null</code>.
 * @return <code>{@link CGlobal#ILLEGAL_ULONG}</code> if the parameter is
 *         <code>null</code>.
 */
@CheckForSigned
public static long getMillis (@Nullable final XMLGregorianCalendar aCal)
{
  final GregorianCalendar aGregorianCalendar = getGregorianCalendar (aCal);
  return aGregorianCalendar == null ? CGlobal.ILLEGAL_ULONG : aGregorianCalendar.getTimeInMillis ();
}