当前位置: 首页>>代码示例>>Java>>正文


Java ICommonsSet.add方法代码示例

本文整理汇总了Java中com.helger.commons.collection.impl.ICommonsSet.add方法的典型用法代码示例。如果您正苦于以下问题:Java ICommonsSet.add方法的具体用法?Java ICommonsSet.add怎么用?Java ICommonsSet.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.helger.commons.collection.impl.ICommonsSet的用法示例。


在下文中一共展示了ICommonsSet.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _testPutRandom

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
private void _testPutRandom (final float fillFactor)
{
  final Random aRandom = RandomHelper.getRandom ();
  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]));
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:24,代码来源:IntObjectMapTest.java

示例2: _testPutRandom

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
private void _testPutRandom (final float fillFactor)
{
  final Random aRandom = RandomHelper.getRandom ();
  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]));
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:24,代码来源:IntIntMapTest.java

示例3: testStringCombination2

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
@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 ());
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:20,代码来源:CombinationGeneratorTest.java

示例4: entrySet

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
@Nonnull
@ReturnsMutableCopy
@CodingStyleguideUnaware
public Set <Map.Entry <KEYTYPE, VALUETYPE>> entrySet ()
{
  final ICommonsSet <Map.Entry <KEYTYPE, VALUETYPE>> aSet = new CommonsHashSet<> (size ());
  if (m_bHasElement)
    aSet.add (new MapEntry<> (m_aKey, m_aValue));
  return aSet;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:11,代码来源:SingleElementMap.java

示例5: testIterator

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
@Test
public void testIterator ()
{
  final Iterator <Charset> iterator = tested.charsets ();
  final ICommonsSet <Charset> found = new CommonsHashSet<> ();
  while (iterator.hasNext ())
    found.add (iterator.next ());
  assertEquals (3, found.size ());
  final Charset charset1 = tested.charsetForName ("x-IMAP4-modified-UTF7");
  final Charset charset2 = tested.charsetForName ("UTF-7");
  final Charset charset3 = tested.charsetForName ("X-UTF-7-OPTIONAL");
  assertTrue (found.contains (charset1));
  assertTrue (found.contains (charset2));
  assertTrue (found.contains (charset3));
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:16,代码来源:UTF7CharsetProviderSPITest.java

示例6: getAllLanguages

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
/**
 * Get all contained locales that consist only of a non-empty language.
 *
 * @return a set with all contained languages, except "all" and "independent"
 */
@Nonnull
@ReturnsMutableCopy
public ICommonsSet <Locale> getAllLanguages ()
{
  final ICommonsSet <Locale> ret = new CommonsHashSet<> ();
  for (final Locale aLocale : getAllLocales ())
  {
    final String sLanguage = aLocale.getLanguage ();
    if (StringHelper.hasText (sLanguage))
      ret.add (getLocale (sLanguage, null, null));
  }
  return ret;
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:19,代码来源:LocaleCache.java

示例7: testStringCombination

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
@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)
  {}
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:28,代码来源:CombinationGeneratorTest.java

示例8: testNoConcurrentModification

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
@Test
public void testNoConcurrentModification ()
{
  final ICommonsSet <Locale> aCountries = new CommonsHashSet<> ();
  for (final String sCountry : CountryCache.getInstance ().getAllCountries ())
    aCountries.add (CountryCache.getInstance ().getCountry (sCountry));

  for (final Locale aCountry : aCountries)
  {
    assertTrue (StringHelper.hasNoText (aCountry.getLanguage ()));
    assertTrue (StringHelper.hasText (aCountry.getCountry ()));
    assertTrue (StringHelper.hasNoText (aCountry.getVariant ()));
  }
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:15,代码来源:CountryCacheTest.java

示例9: testGetAllCountries

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
@Ignore
@Test
public void testGetAllCountries ()
{
  final ICommonsSet <String> aSet = new CommonsTreeSet <> ();
  for (final Locale aLocale : LocaleCache.getInstance ().getAllLocales ())
    for (final Locale aLocale2 : LocaleCache.getInstance ().getAllLocales ())
      aSet.add (aLocale.getDisplayCountry (aLocale2));
  for (final String sUnique : aSet)
    s_aLogger.info (sUnique);
}
 
开发者ID:phax,项目名称:ph-masterdata,代码行数:12,代码来源:VehicleSignsFuncTest.java

示例10: CodePart60

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
CodePart60(
    @Nonnull
    final ICommonsSet<String> aCodeSet) {
    aCodeSet.add("ZWUTA");
    aCodeSet.add("ZWMUT");
    aCodeSet.add("ZWSTH");
    aCodeSet.add("ZWTHJ");
    aCodeSet.add("ZWVFA");
}
 
开发者ID:phax,项目名称:ph-ubl,代码行数:10,代码来源:CPortCode21.java

示例11: NamePart60

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
NamePart60(
    @Nonnull
    final ICommonsSet<String> aNameSet) {
    aNameSet.add("Mutare");
    aNameSet.add("Mutoko");
    aNameSet.add("Southerton");
    aNameSet.add("Thompson Junction");
    aNameSet.add("Victoria Falls");
}
 
开发者ID:phax,项目名称:ph-ubl,代码行数:10,代码来源:CPortCode21.java

示例12: printUsage

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
/**
 * Prints the usage statement for the specified application.
 *
 * @param aPW
 *        The PrintWriter to print the usage statement
 * @param nWidth
 *        The number of characters to display per line
 * @param sAppName
 *        The application name
 * @param aOptions
 *        The command line Options
 */
public void printUsage (@Nonnull final PrintWriter aPW,
                        final int nWidth,
                        final String sAppName,
                        final Options aOptions)
{
  // initialise the string buffer
  final StringBuilder aSB = new StringBuilder (getSyntaxPrefix ()).append (sAppName).append (' ');

  // create a list for processed option groups
  final ICommonsSet <OptionGroup> aProcessedGroups = new CommonsHashSet <> ();

  final ICommonsList <Option> aOptList = aOptions.getAllResolvedOptions ();
  if (m_aOptionComparator != null)
    aOptList.sort (m_aOptionComparator);

  // iterate over the options
  for (final Iterator <Option> aIt = aOptList.iterator (); aIt.hasNext ();)
  {
    // get the next Option
    final Option aOption = aIt.next ();

    // check if the option is part of an OptionGroup
    final OptionGroup group = aOptions.getOptionGroup (aOption);

    // if the option is part of a group
    if (group != null)
    {
      // and if the group has not already been processed
      if (aProcessedGroups.add (group))
      {
        // add the usage clause
        _appendOptionGroup (aSB, group);
      }

      // otherwise the option was displayed in the group
      // previously so ignore it.
    }
    else
    {
      // if the Option is not part of an OptionGroup
      _appendOption (aSB, aOption, aOption.isRequired ());
    }

    if (aIt.hasNext ())
      aSB.append (' ');
  }

  // call printWrapped
  printWrapped (aPW, nWidth, aSB.toString ().indexOf (' ') + 1, aSB.toString ());
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:63,代码来源:HelpFormatter.java

示例13: main

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
public static void main (final String [] args)
{
  // UBL 2.2
  {
    System.out.println ("UBL 2.2");
    final IMicroDocument eDoc = _createBaseDoc ();
    final ICommonsSet <String> aNamespaces = new CommonsHashSet <> ();
    for (final String sPart : new String [] { "common", "maindoc" })
    {
      final String sBasePath = BASE_XSD_PATH + sPart;
      for (final File aFile : _getFileList ("src/main" + sBasePath))
      {
        // Each namespace should handled only once
        final IMicroDocument aDoc = MicroReader.readMicroXML (new FileSystemResource (aFile));
        final String sTargetNamespace = _getTargetNamespace (aDoc);
        if (!aNamespaces.add (sTargetNamespace))
        {
          System.out.println ("Ignored namespace URI " + sTargetNamespace + " in " + aFile.getName ());
          continue;
        }
        String sPackageName = _convertToPackage (sTargetNamespace);
        if (sPackageName.endsWith ("_2"))
        {
          // Change "_2" to "_22"
          sPackageName += "2";
        }
        // schemaLocation must be relative to bindings file!
        final IMicroElement eBindings = eDoc.getDocumentElement ()
                                            .appendElement (JAXB_NS_URI, "bindings")
                                            .setAttribute ("schemaLocation",
                                                           ".." + sBasePath + "/" + aFile.getName ())
                                            .setAttribute ("node", "/xsd:schema");
        eBindings.appendElement (JAXB_NS_URI, "schemaBindings")
                 .appendElement (JAXB_NS_URI, "package")
                 .setAttribute ("name", sPackageName);
      }
    }
    MicroWriter.writeToFile (eDoc,
                             new File (DEFAULT_BINDING_FILE),
                             new XMLWriterSettings ().setIncorrectCharacterHandling (EXMLIncorrectCharacterHandling.DO_NOT_WRITE_LOG_WARNING)
                                                     .setNamespaceContext (new MapBasedNamespaceContext ().addMapping (XMLConstants.DEFAULT_NS_PREFIX,
                                                                                                                       JAXB_NS_URI)
                                                                                                          .addMapping ("xsd",
                                                                                                                       XMLConstants.W3C_XML_SCHEMA_NS_URI)
                                                                                                          .addMapping ("xsi",
                                                                                                                       XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI))
                                                     .setPutNamespaceContextPrefixesInRoot (true));
  }

  System.out.println ("Done");
}
 
开发者ID:phax,项目名称:ph-ubl,代码行数:52,代码来源:MainCreateJAXBBinding22.java

示例14: main

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
public static void main (final String [] args)
{
  // UBL 2.1
  {
    System.out.println ("UBL 2.1");
    final IMicroDocument eDoc = _createBaseDoc ();
    final ICommonsSet <String> aNamespaces = new CommonsHashSet <> ();
    for (final String sPart : new String [] { "common", "maindoc" })
    {
      final String sBasePath = BASE_XSD_PATH + sPart;
      for (final File aFile : _getFileList ("src/main" + sBasePath))
      {
        // Each namespace should handled only once
        final IMicroDocument aDoc = MicroReader.readMicroXML (new FileSystemResource (aFile));
        final String sTargetNamespace = _getTargetNamespace (aDoc);
        if (!aNamespaces.add (sTargetNamespace))
        {
          System.out.println ("Ignored " + sTargetNamespace + " in " + aFile.getName ());
          continue;
        }
        String sPackageName = _convertToPackage (sTargetNamespace);
        if (sPackageName.endsWith ("_2"))
        {
          // Change "_2" to "_21"
          sPackageName += "1";
        }
        // schemaLocation must be relative to bindings file!
        final IMicroElement eBindings = eDoc.getDocumentElement ()
                                            .appendElement (JAXB_NS_URI, "bindings")
                                            .setAttribute ("schemaLocation",
                                                           ".." + sBasePath + "/" + aFile.getName ())
                                            .setAttribute ("node", "/xsd:schema");
        eBindings.appendElement (JAXB_NS_URI, "schemaBindings")
                 .appendElement (JAXB_NS_URI, "package")
                 .setAttribute ("name", sPackageName);
      }
    }
    MicroWriter.writeToFile (eDoc,
                             new File (DEFAULT_BINDING_FILE),
                             new XMLWriterSettings ().setIncorrectCharacterHandling (EXMLIncorrectCharacterHandling.DO_NOT_WRITE_LOG_WARNING)
                                                     .setNamespaceContext (new MapBasedNamespaceContext ().addMapping (XMLConstants.DEFAULT_NS_PREFIX,
                                                                                                                       JAXB_NS_URI)
                                                                                                          .addMapping ("xsd",
                                                                                                                       XMLConstants.W3C_XML_SCHEMA_NS_URI)
                                                                                                          .addMapping ("xsi",
                                                                                                                       XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI))
                                                     .setPutNamespaceContextPrefixesInRoot (true));
  }

  System.out.println ("Done");
}
 
开发者ID:phax,项目名称:ph-ubl,代码行数:52,代码来源:MainCreateJAXBBinding21.java

示例15: main

import com.helger.commons.collection.impl.ICommonsSet; //导入方法依赖的package包/类
public static void main (final String [] args)
{
  // UBL 2.0
  {
    System.out.println ("UBL 2.0");
    final IMicroDocument eDoc = _createBaseDoc ();
    final ICommonsSet <String> aNamespaces = new CommonsHashSet <> ();
    for (final String sPart : new String [] { "common", "maindoc" })
    {
      final String sBasePath = "/resources/schemas/ubl20/" + sPart;
      for (final File aFile : _getFileList ("src/main" + sBasePath))
      {
        // Each namespace should handled only once
        final IMicroDocument aDoc = MicroReader.readMicroXML (new FileSystemResource (aFile));
        final String sTargetNamespace = _getTargetNamespace (aDoc);
        if (!aNamespaces.add (sTargetNamespace))
        {
          System.out.println ("Ignored " + sTargetNamespace + " in " + aFile.getName ());
          continue;
        }
        final String sPackageName = _convertToPackage (sTargetNamespace);
        // schemaLocation must be relative to bindings file!
        final IMicroElement eBindings = eDoc.getDocumentElement ()
                                            .appendElement (JAXB_NS_URI, "bindings")
                                            .setAttribute ("schemaLocation",
                                                           ".." + sBasePath + "/" + aFile.getName ())
                                            .setAttribute ("node", "/xsd:schema");

        eBindings.appendElement (JAXB_NS_URI, "schemaBindings")
                 .appendElement (JAXB_NS_URI, "package")
                 .setAttribute ("name", sPackageName);

        if (aFile.getName ().equals ("CodeList_UnitCode_UNECE_7_04.xsd") ||
            aFile.getName ().equals ("CodeList_LanguageCode_ISO_7_04.xsd"))
        {
          _generateExplicitEnumMapping (aDoc, aFile.getName (), eBindings);
        }
      }
    }
    MicroWriter.writeToFile (eDoc,
                             new File ("src/main/jaxb/bindings20.xjb"),
                             new XMLWriterSettings ().setIncorrectCharacterHandling (EXMLIncorrectCharacterHandling.DO_NOT_WRITE_LOG_WARNING)
                                                     .setNamespaceContext (new MapBasedNamespaceContext ().addMapping (XMLConstants.DEFAULT_NS_PREFIX,
                                                                                                                       JAXB_NS_URI)
                                                                                                          .addMapping ("xsd",
                                                                                                                       XMLConstants.W3C_XML_SCHEMA_NS_URI)
                                                                                                          .addMapping ("xsi",
                                                                                                                       XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI))
                                                     .setPutNamespaceContextPrefixesInRoot (true));
  }

  System.out.println ("Done");
}
 
开发者ID:phax,项目名称:ph-ubl,代码行数:54,代码来源:MainCreateJAXBBinding20.java


注:本文中的com.helger.commons.collection.impl.ICommonsSet.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。