javax.annotation.concurrent.Immutable#com.helger.commons.collection.impl.ICommonsSet源码实例Demo

下面列出了javax.annotation.concurrent.Immutable#com.helger.commons.collection.impl.ICommonsSet 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ph-commons   文件: IntObjectMapTest.java
private void _testPutRandom (final float fillFactor)
{
  final Random aRandom = new Random ();
  final int SIZE = 100 * 1000;
  final ICommonsSet <Integer> set = new CommonsHashSet <> (SIZE);
  final int [] vals = new int [SIZE];
  while (set.size () < SIZE)
    set.add (Integer.valueOf (aRandom.nextInt ()));
  int i = 0;
  for (final Integer v : set)
    vals[i++] = v.intValue ();

  final IntObjectMap <String> map = _makeMap (100, fillFactor);
  for (i = 0; i < vals.length; ++i)
  {
    assertNull ("Inserting " + vals[i], map.put (vals[i], _make (vals[i])));
    assertEquals (i + 1, map.size ());
    assertEquals (_make (vals[i]), map.get (vals[i]));
  }
  // now check the final state
  for (i = 0; i < vals.length; ++i)
    assertEquals (_make (vals[i]), map.get (vals[i]));
}
 
源代码2 项目: ph-commons   文件: IntIntMapTest.java
private void _testPutRandom (final float fillFactor)
{
  final Random aRandom = new Random ();
  final int SIZE = 100 * 1000;
  final ICommonsSet <Integer> set = new CommonsHashSet <> (SIZE);
  final int [] vals = new int [SIZE];
  while (set.size () < SIZE)
    set.add (Integer.valueOf (aRandom.nextInt ()));
  int i = 0;
  for (final Integer v : set)
    vals[i++] = v.intValue ();

  final IntIntMap map = _makeMap (100, fillFactor);
  for (i = 0; i < vals.length; ++i)
  {
    assertEquals (0, map.put (vals[i], vals[i]));
    assertEquals (i + 1, map.size ());
    assertEquals (vals[i], map.get (vals[i]));
  }
  // now check the final state
  for (i = 0; i < vals.length; ++i)
    assertEquals (vals[i], map.get (vals[i]));
}
 
源代码3 项目: ph-commons   文件: CombinationGeneratorTest.java
@Test
public void testStringCombination2 ()
{
  final ICommonsList <String> aElements = new CommonsArrayList <> (A, B, B, C);
  final CombinationGenerator <String> x = new CombinationGenerator <> (aElements, 0);
  assertEquals (BigInteger.ONE, x.getTotalCombinations ());
  assertEquals (BigInteger.ONE, x.getCombinationsLeft ());

  final ICommonsList <ICommonsList <String>> aResultsWithDuplicates = new CommonsArrayList <> ();
  final ICommonsSet <ICommonsList <String>> aResultsWithoutDuplicates = new CommonsHashSet <> ();
  while (x.hasNext ())
  {
    final ICommonsList <String> aResult = x.next ();
    aResultsWithDuplicates.add (aResult);
    aResultsWithoutDuplicates.add (aResult);
  }
  assertEquals (1, aResultsWithDuplicates.size ());
  assertEquals (1, aResultsWithoutDuplicates.size ());
}
 
@Ignore ("Simply wrong assumption")
@Test
public void testRedundancy ()
{
  final ICommonsList <String> aInputList = new CommonsArrayList <> ("a", "b", "c", "d", "e", "f", "g", "h");

  // Build all permutations of the input list, using all available slots
  final ICommonsSet <ICommonsList <String>> aSimplePermutations = new CommonsHashSet <> ();
  CombinationGenerator.addAllPermutations (aInputList, aInputList.size (), aSimplePermutations);

  // Flexible combination generator
  final ICommonsSet <ICommonsList <String>> aFlexiblePermutations = CombinationGeneratorFlexible.getCombinations (aInputList,
                                                                                                                  true);
  assertTrue (aFlexiblePermutations.size () >= aSimplePermutations.size ());

  // Now the assumptions: I assume that all permutations from the flexible
  // generator are also contained in all permutations
  for (final ICommonsList <String> aList : aFlexiblePermutations)
    assertTrue (aList.toString (), aSimplePermutations.contains (aList));
}
 
源代码5 项目: ph-ubl   文件: EUBL23DocumentTypeTest.java
@Test
public void testAll ()
{
  final ICommonsSet <Class <?>> aClasses = new CommonsHashSet <> ();
  final ICommonsSet <String> aFilenames = new CommonsHashSet <> ();
  for (final EUBL23DocumentType e : EUBL23DocumentType.values ())
  {
    assertNotNull (e.getImplementationClass ());
    assertTrue (StringHelper.hasText (e.getLocalName ()));
    assertTrue (StringHelper.hasText (e.getNamespaceURI ()));
    assertTrue (e.getAllXSDResources ().size () >= 1);
    for (final IReadableResource aRes : e.getAllXSDResources ())
      assertTrue (e.name (), aRes.exists ());
    assertNotNull (e.getSchema ());
    assertSame (e.getSchema (), e.getSchema ());
    assertSame (e, EUBL23DocumentType.valueOf (e.name ()));
    assertTrue (aClasses.add (e.getImplementationClass ()));
    assertTrue (aFilenames.add (e.getAllXSDResources ().getFirst ().getPath ()));
  }
}
 
源代码6 项目: ph-commons   文件: CollectionHelper.java
@Nonnull
@ReturnsMutableCopy
@SafeVarargs
public static <ELEMENTTYPE> ICommonsSet <ELEMENTTYPE> getConcatenatedSet (@Nullable final Collection <? extends ELEMENTTYPE> aCont1,
                                                                          @Nullable final ELEMENTTYPE... aCont2)
{
  final int nSize1 = getSize (aCont1);
  if (nSize1 == 0)
    return newSet (aCont2);

  final int nSize2 = ArrayHelper.getSize (aCont2);
  if (nSize2 == 0)
    return newSet (aCont1);

  final ICommonsSet <ELEMENTTYPE> ret = newSet (nSize1 + nSize2);
  ret.addAll (aCont1);
  Collections.addAll (ret, aCont2);
  return ret;
}
 
源代码7 项目: ph-commons   文件: CombinationGeneratorTest.java
@Test
public void testStringCombination ()
{
  final ICommonsList <String> aElements = new CommonsArrayList <> (A, B, B, C);
  final CombinationGenerator <String> x = new CombinationGenerator <> (aElements, 3);
  assertEquals (BigInteger.valueOf (4), x.getTotalCombinations ());
  assertEquals (BigInteger.valueOf (4), x.getCombinationsLeft ());

  final ICommonsList <ICommonsList <String>> aResultsWithDuplicates = new CommonsArrayList <> ();
  final ICommonsSet <ICommonsList <String>> aResultsWithoutDuplicates = new CommonsHashSet <> ();
  while (x.hasNext ())
  {
    final ICommonsList <String> aResult = x.next ();
    aResultsWithDuplicates.add (aResult);
    aResultsWithoutDuplicates.add (aResult);
  }
  assertEquals (4, aResultsWithDuplicates.size ());
  assertEquals (3, aResultsWithoutDuplicates.size ());

  try
  {
    x.remove ();
    fail ();
  }
  catch (final UnsupportedOperationException ex)
  {}
}
 
源代码8 项目: ph-ubl   文件: UBL21DocumentTypes.java
/**
 * @return A non-<code>null</code> set of all supported UBL 2.1 document
 *         element local names.
 */
@Nonnull
@ReturnsMutableCopy
public static ICommonsSet <String> getAllLocalNames ()
{
  return s_aLocalName2DocType.copyOfKeySet ();
}
 
源代码9 项目: ph-ubl   文件: DianUBLDocumentTypes.java
/**
 * @return A non-<code>null</code> set of all supported UBLPE document element
 *         local names.
 */
@Nonnull
@ReturnsMutableCopy
public static ICommonsSet <String> getAllLocalNames ()
{
  return s_aLocalName2DocType.copyOfKeySet ();
}
 
源代码10 项目: ph-ubl   文件: UBL22DocumentTypes.java
/**
 * @return A non-<code>null</code> set of all supported UBL 2.2 document
 *         element local names.
 */
@Nonnull
@ReturnsMutableCopy
public static ICommonsSet <String> getAllLocalNames ()
{
  return s_aLocalName2DocType.copyOfKeySet ();
}
 
源代码11 项目: ph-commons   文件: AuthTokenIDGeneratorTest.java
@Test
public void testAll ()
{
  // Ensure they are unique....
  final ICommonsSet <String> aAll = new CommonsHashSet <> ();
  for (int i = 0; i < 1000; i++)
    assertTrue (aAll.add (AuthTokenIDGenerator.generateNewTokenID ()));
}
 
@Test
public void testAll ()
{
  IMultiMapSetBased <String, String, ? extends ICommonsSet <String>> aMultiMap = new MultiTreeMapLinkedHashSetBased <> ();
  testEmpty (aMultiMap);
  aMultiMap = new MultiTreeMapLinkedHashSetBased <> (getKey1 (), getValue1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiTreeMapLinkedHashSetBased <> (getKey1 (), getValueSetOrdered1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiTreeMapLinkedHashSetBased <> (getMapSetOrdered1 ());
  testOne (aMultiMap);
}
 
@Test
public void testAll ()
{
  IMultiMapSetBased <String, String, ? extends ICommonsSet <String>> aMultiMap = new MultiConcurrentHashMapHashSetBased <> ();
  testEmpty (aMultiMap);
  aMultiMap = new MultiConcurrentHashMapHashSetBased <> (getKey1 (), getValue1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiConcurrentHashMapHashSetBased <> (getKey1 (), getValueSet1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiConcurrentHashMapHashSetBased <> (getMapSet1 ());
  testOne (aMultiMap);
}
 
@Test
public void testAll ()
{
  IMultiMapSetBased <String, String, ? extends ICommonsSet <String>> aMultiMap = new MultiWeakHashMapLinkedHashSetBased <> ();
  testEmpty (aMultiMap);
  aMultiMap = new MultiWeakHashMapLinkedHashSetBased <> (getKey1 (), getValue1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiWeakHashMapLinkedHashSetBased <> (getKey1 (), getValueSetOrdered1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiWeakHashMapLinkedHashSetBased <> (getMapSetOrdered1 ());
  testOne (aMultiMap);
}
 
@Test
public void testAll ()
{
  IMultiMapSetBased <String, String, ? extends ICommonsSet <String>> aMultiMap = new MultiConcurrentHashMapLinkedHashSetBased <> ();
  testEmpty (aMultiMap);
  aMultiMap = new MultiConcurrentHashMapLinkedHashSetBased <> (getKey1 (), getValue1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiConcurrentHashMapLinkedHashSetBased <> (getKey1 (), getValueSetOrdered1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiConcurrentHashMapLinkedHashSetBased <> (getMapSetOrdered1 ());
  testOne (aMultiMap);
}
 
@Test
public void testAll ()
{
  IMultiMapSetBased <String, String, ? extends ICommonsSet <String>> aMultiMap = new MultiLinkedHashMapTreeSetBased <> ();
  testEmpty (aMultiMap);
  aMultiMap = new MultiLinkedHashMapTreeSetBased <> (getKey1 (), getValue1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiLinkedHashMapTreeSetBased <> (getKey1 (), getValueSetNavigable1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiLinkedHashMapTreeSetBased <> (getMapSetNavigable1 ());
  testOne (aMultiMap);
}
 
@Test
public void testAll ()
{
  IMultiMapSetBased <String, String, ? extends ICommonsSet <String>> aMultiMap = new MultiWeakHashMapHashSetBased <> ();
  testEmpty (aMultiMap);
  aMultiMap = new MultiWeakHashMapHashSetBased <> (getKey1 (), getValue1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiWeakHashMapHashSetBased <> (getKey1 (), getValueSet1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiWeakHashMapHashSetBased <> (getMapSet1 ());
  testOne (aMultiMap);
}
 
源代码18 项目: ph-commons   文件: MultiHashMapTreeSetBasedTest.java
@Test
public void testAll ()
{
  IMultiMapSetBased <String, String, ? extends ICommonsSet <String>> aMultiMap = new MultiHashMapTreeSetBased <> ();
  testEmpty (aMultiMap);
  aMultiMap = new MultiHashMapTreeSetBased <> (getKey1 (), getValue1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiHashMapTreeSetBased <> (getKey1 (), getValueSetNavigable1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiHashMapTreeSetBased <> (getMapSetNavigable1 ());
  testOne (aMultiMap);
}
 
@Test
public void testAll ()
{
  IMultiMapSetBased <String, String, ? extends ICommonsSet <String>> aMultiMap = new MultiLinkedHashMapLinkedHashSetBased <> ();
  testEmpty (aMultiMap);
  aMultiMap = new MultiLinkedHashMapLinkedHashSetBased <> (getKey1 (), getValue1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiLinkedHashMapLinkedHashSetBased <> (getKey1 (), getValueSetOrdered1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiLinkedHashMapLinkedHashSetBased <> (getMapSetOrdered1 ());
  testOne (aMultiMap);
}
 
源代码20 项目: ph-commons   文件: MultiHashMapHashSetBasedTest.java
@Test
public void testAll ()
{
  IMultiMapSetBased <String, String, ? extends ICommonsSet <String>> aMultiMap = new MultiHashMapHashSetBased <> ();
  testEmpty (aMultiMap);
  aMultiMap = new MultiHashMapHashSetBased <> (getKey1 (), getValue1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiHashMapHashSetBased <> (getKey1 (), getValueSet1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiHashMapHashSetBased <> (getMapSet1 ());
  testOne (aMultiMap);
}
 
@Test
public void testAll ()
{
  IMultiMapSetBased <String, String, ? extends ICommonsSet <String>> aMultiMap = new MultiWeakHashMapTreeSetBased <> ();
  testEmpty (aMultiMap);
  aMultiMap = new MultiWeakHashMapTreeSetBased <> (getKey1 (), getValue1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiWeakHashMapTreeSetBased <> (getKey1 (), getValueSetNavigable1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiWeakHashMapTreeSetBased <> (getMapSetNavigable1 ());
  testOne (aMultiMap);
}
 
源代码22 项目: ph-commons   文件: StringHelperTest.java
@Test
public void testExplodeToSet ()
{
  ICommonsSet <String> ret = StringHelper.getExplodedToSet ("@", "[email protected]@@c");
  assertEquals (new CommonsHashSet <> ("a", "b", "", "c"), ret);
  ret = StringHelper.getExplodedToSet ("uu", "auubuuuuuuc");
  assertEquals (new CommonsHashSet <> ("a", "b", "", "", "c"), ret);
  ret = StringHelper.getExplodedToSet (".", "a.b...c");
  assertEquals (new CommonsHashSet <> ("a", "b", "", "", "c"), ret);
  ret = StringHelper.getExplodedToSet ("o", "boo:and:foo");
  assertEquals (new CommonsHashSet <> ("b", "", ":and:f", "", ""), ret);
  ret = StringHelper.getExplodedToSet ("@", "@[email protected]@@c");
  assertEquals (new CommonsHashSet <> ("", "a", "b", "", "c"), ret);
  ret = StringHelper.getExplodedToSet ("@", "[email protected]@@[email protected]");
  assertEquals (new CommonsHashSet <> ("a", "b", "", "c", ""), ret);
  ret = StringHelper.getExplodedToSet ("@", "@[email protected]@@[email protected]");
  assertEquals (new CommonsHashSet <> ("", "a", "b", "", "c", ""), ret);
  assertTrue (StringHelper.getExplodedToSet ("@", null).isEmpty ());

  try
  {
    StringHelper.getExplodedToSet (null, "@[email protected]@@[email protected]");
    fail ();
  }
  catch (final NullPointerException ex)
  {}
}
 
源代码23 项目: ph-commons   文件: MultiTreeMapTreeSetBasedTest.java
@Test
public void testAll ()
{
  IMultiMapSetBased <String, String, ? extends ICommonsSet <String>> aMultiMap = new MultiTreeMapTreeSetBased <> ();
  testEmpty (aMultiMap);
  aMultiMap = new MultiTreeMapTreeSetBased <> (getKey1 (), getValue1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiTreeMapTreeSetBased <> (getKey1 (), getValueSetNavigable1 ());
  testOne (aMultiMap);
  aMultiMap = new MultiTreeMapTreeSetBased <> (getMapSetNavigable1 ());
  testOne (aMultiMap);
}
 
源代码24 项目: ph-commons   文件: CollectionHelperTest.java
@Test
@SuppressFBWarnings ("NP_NONNULL_PARAM_VIOLATION")
public void testMakeUnmodifiableNotNull ()
{
  assertNotNull (makeUnmodifiableNotNull ((Collection <?>) null));
  assertNotNull (makeUnmodifiableNotNull ((ICommonsList <?>) null));
  assertNotNull (makeUnmodifiableNotNull ((Set <?>) null));
  assertNotNull (makeUnmodifiableNotNull ((SortedSet <?>) null));
  assertNotNull (makeUnmodifiableNotNull ((Map <?, ?>) null));
  assertNotNull (makeUnmodifiableNotNull ((SortedMap <?, ?>) null));

  final ICommonsCollection <String> c = newList ("s1", "s2");
  assertNotNull (makeUnmodifiableNotNull (c));
  assertNotSame (c, makeUnmodifiableNotNull (c));
  final ICommonsList <String> l = newList ("s1", "s2");
  assertNotNull (makeUnmodifiableNotNull (l));
  assertNotSame (l, makeUnmodifiableNotNull (l));
  final ICommonsSet <String> s = newSet ("s1", "s2");
  assertNotNull (makeUnmodifiableNotNull (s));
  assertNotSame (s, makeUnmodifiableNotNull (s));
  final ICommonsSortedSet <String> ss = new CommonsTreeSet <> (s);
  assertNotNull (makeUnmodifiableNotNull (ss));
  assertNotSame (ss, makeUnmodifiableNotNull (ss));
  final ICommonsMap <String, String> m = newMap ("s1", "s2");
  assertNotNull (makeUnmodifiableNotNull (m));
  assertNotSame (m, makeUnmodifiableNotNull (m));
  final ICommonsSortedMap <String, String> sm = new CommonsTreeMap <> (m);
  assertNotNull (makeUnmodifiableNotNull (sm));
  assertNotSame (sm, makeUnmodifiableNotNull (sm));
}
 
源代码25 项目: ph-commons   文件: SystemProperties.java
/**
 * @return A copy of the set with all property names for which warnings were
 *         emitted.
 */
@Nonnull
@ReturnsMutableCopy
public static ICommonsSet <String> getAllWarnedPropertyNames ()
{
  // Convert from CopyOnWrite to regular HashSet
  return new CommonsHashSet <> (s_aWarnedPropertyNames);
}
 
源代码26 项目: ph-commons   文件: DirectedGraphNode.java
@Nonnull
@ReturnsMutableCopy
public ICommonsSet <IMutableDirectedGraphNode> getAllFromNodes ()
{
  final ICommonsSet <IMutableDirectedGraphNode> ret = new CommonsHashSet <> ();
  if (m_aIncoming != null)
    CollectionHelper.findAllMapped (m_aIncoming.values (), IMutableDirectedGraphRelation::getFrom, ret::add);
  return ret;
}
 
源代码27 项目: ph-commons   文件: DirectedGraphNode.java
@Nonnull
@ReturnsMutableCopy
public ICommonsSet <IMutableDirectedGraphNode> getAllToNodes ()
{
  final ICommonsSet <IMutableDirectedGraphNode> ret = new CommonsHashSet <> ();
  if (m_aOutgoing != null)
    CollectionHelper.findAllMapped (m_aOutgoing.values (), IMutableDirectedGraphRelation::getTo, ret::add);
  return ret;
}
 
源代码28 项目: ph-commons   文件: CountryCacheTest.java
@Test
public void testNoConcurrentModificationString ()
{
  final ICommonsSet <Locale> aCountries = new CommonsHashSet <> ();
  for (final String sCountry : CountryCache.getInstance ().getAllCountries ())
    aCountries.add (CountryCache.getInstance ().getCountry (sCountry));

  for (final Locale aCountry : aCountries)
  {
    assertNotNull (aCountry);
    assertTrue (StringHelper.hasNoText (aCountry.getLanguage ()));
    assertTrue (StringHelper.hasText (aCountry.getCountry ()));
    assertTrue (StringHelper.hasNoText (aCountry.getVariant ()));
  }
}
 
源代码29 项目: ph-commons   文件: XMLCharsetDeterminator.java
/**
 * @return A mutable Set with all charsets that can be used for the charset
 *         determination. Never <code>null</code>.
 */
@Nonnull
@ReturnsMutableCopy
public static ICommonsSet <Charset> getAllSupportedCharsets ()
{
  return XML_CHARSETS.getClone ();
}
 
源代码30 项目: ph-ubl   文件: UBL22DocumentTypes.java
/**
 * @return A non-<code>null</code> set of all supported UBL 2.2 namespaces.
 */
@Nonnull
@ReturnsMutableCopy
public static ICommonsSet <String> getAllNamespaces ()
{
  return s_aNamespace2DocType.copyOfKeySet ();
}