Java Code Examples for com.helger.commons.collection.CollectionHelper#getSize()

The following examples show how to use com.helger.commons.collection.CollectionHelper#getSize() . 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: CommonsVector.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
@ReturnsMutableCopy
public static <SRCTYPE, ELEMENTTYPE> CommonsVector <ELEMENTTYPE> createFiltered (@Nullable final Iterable <? extends SRCTYPE> aValues,
                                                                                 @Nullable final Predicate <? super SRCTYPE> aFilter,
                                                                                 @Nonnull final Function <? super SRCTYPE, ? extends ELEMENTTYPE> aMapper)
{
  final CommonsVector <ELEMENTTYPE> ret = new CommonsVector <> (CollectionHelper.getSize (aValues));
  ret.addAllMapped (aValues, aFilter, aMapper);
  return ret;
}
 
Example 2
Source File: CommonsWeakHashMap.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
public <SRCKEYTYPE, SRCVALUETYPE> CommonsWeakHashMap (@Nullable final Map <? extends SRCKEYTYPE, ? extends SRCVALUETYPE> aValues,
                                                      @Nonnull final Function <? super SRCKEYTYPE, ? extends KEYTYPE> aKeyMapper,
                                                      @Nonnull final Function <? super SRCVALUETYPE, ? extends VALUETYPE> aValueMapper)
{
  super (CollectionHelper.getSize (aValues));
  putAllMapped (aValues, aKeyMapper, aValueMapper);
}
 
Example 3
Source File: CommonsWeakHashMap.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
public <COLLTYPE> CommonsWeakHashMap (@Nullable final Collection <? extends COLLTYPE> aValues,
                                      @Nonnull final Function <? super COLLTYPE, ? extends KEYTYPE> aKeyMapper,
                                      @Nonnull final Function <? super COLLTYPE, ? extends VALUETYPE> aValueMapper)
{
  super (CollectionHelper.getSize (aValues));
  putAllMapped (aValues, aKeyMapper, aValueMapper);
}
 
Example 4
Source File: CommonsHashMap.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
public <COLLTYPE> CommonsHashMap (@Nullable final Collection <? extends COLLTYPE> aValues,
                                  @Nonnull final Function <? super COLLTYPE, ? extends KEYTYPE> aKeyMapper,
                                  @Nonnull final Function <? super COLLTYPE, ? extends VALUETYPE> aValueMapper)
{
  super (CollectionHelper.getSize (aValues));
  putAllMapped (aValues, aKeyMapper, aValueMapper);
}
 
Example 5
Source File: CommonsConcurrentHashMap.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
public <COLLTYPE> CommonsConcurrentHashMap (@Nullable final Collection <? extends COLLTYPE> aValues,
                                            @Nonnull final Function <? super COLLTYPE, ? extends KEYTYPE> aKeyMapper,
                                            @Nonnull final Function <? super COLLTYPE, ? extends VALUETYPE> aValueMapper)
{
  super (CollectionHelper.getSize (aValues));
  putAllMapped (aValues, aKeyMapper, aValueMapper);
}
 
Example 6
Source File: CommonsLinkedHashMap.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
public <SRCKEYTYPE, SRCVALUETYPE> CommonsLinkedHashMap (@Nullable final Map <? extends SRCKEYTYPE, ? extends SRCVALUETYPE> aValues,
                                                        @Nonnull final Function <? super SRCKEYTYPE, ? extends KEYTYPE> aKeyMapper,
                                                        @Nonnull final Function <? super SRCVALUETYPE, ? extends VALUETYPE> aValueMapper)
{
  super (CollectionHelper.getSize (aValues));
  putAllMapped (aValues, aKeyMapper, aValueMapper);
}
 
Example 7
Source File: CommonsHashMap.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
public <SRCKEYTYPE, SRCVALUETYPE> CommonsHashMap (@Nullable final Map <? extends SRCKEYTYPE, ? extends SRCVALUETYPE> aValues,
                                                  @Nonnull final Function <? super SRCKEYTYPE, ? extends KEYTYPE> aKeyMapper,
                                                  @Nonnull final Function <? super SRCVALUETYPE, ? extends VALUETYPE> aValueMapper)
{
  super (CollectionHelper.getSize (aValues));
  putAllMapped (aValues, aKeyMapper, aValueMapper);
}
 
Example 8
Source File: XMLHelper.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Nonnegative
public static int getDirectChildElementCountNoNS (@Nullable final Element aParent)
{
  return aParent == null ? 0 : CollectionHelper.getSize (getChildElementIteratorNoNS (aParent));
}
 
Example 9
Source File: CommonsLinkedHashSet.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
public <SRCTYPE> CommonsLinkedHashSet (@Nullable final Collection <? extends SRCTYPE> aValues,
                                       @Nonnull final Function <? super SRCTYPE, ? extends ELEMENTTYPE> aMapper)
{
  super (CollectionHelper.getSize (aValues));
  addAllMapped (aValues, aMapper);
}
 
Example 10
Source File: CommonsVector.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
public CommonsVector (@Nullable final Collection <? extends ELEMENTTYPE> aCont)
{
  super (CollectionHelper.getSize (aCont));
  if (aCont != null)
    addAll (aCont);
}
 
Example 11
Source File: CommonsLinkedHashSet.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
public CommonsLinkedHashSet (@Nullable final Collection <? extends ELEMENTTYPE> aCont)
{
  super (CollectionHelper.getSize (aCont));
  if (aCont != null)
    addAll (aCont);
}
 
Example 12
Source File: CommonsHashSet.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
public <SRCTYPE> CommonsHashSet (@Nullable final Collection <? extends SRCTYPE> aValues,
                                 @Nonnull final Function <? super SRCTYPE, ? extends ELEMENTTYPE> aMapper)
{
  super (CollectionHelper.getSize (aValues));
  addAllMapped (aValues, aMapper);
}
 
Example 13
Source File: CommonsHashSet.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
public CommonsHashSet (@Nullable final Collection <? extends ELEMENTTYPE> aCont)
{
  super (CollectionHelper.getSize (aCont));
  if (aCont != null)
    addAll (aCont);
}
 
Example 14
Source File: CommonsConcurrentHashMap.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
public CommonsConcurrentHashMap (@Nullable final Map <? extends KEYTYPE, ? extends VALUETYPE> aMap)
{
  super (CollectionHelper.getSize (aMap));
  if (aMap != null)
    putAll (aMap);
}
 
Example 15
Source File: CommonsWeakHashMap.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
public CommonsWeakHashMap (@Nullable final Map <? extends KEYTYPE, ? extends VALUETYPE> aMap)
{
  super (CollectionHelper.getSize (aMap));
  if (aMap != null)
    putAll (aMap);
}
 
Example 16
Source File: XMLHelper.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Nonnegative
public static int getDirectChildElementCountNoNS (@Nullable final Element aParent,
                                                  @Nonnull @Nonempty final String sTagName)
{
  return aParent == null ? 0 : CollectionHelper.getSize (getChildElementIteratorNoNS (aParent, sTagName));
}
 
Example 17
Source File: XMLHelper.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
@Nonnegative
public static int getDirectChildElementCount (@Nullable final Element aParent)
{
  return aParent == null ? 0 : CollectionHelper.getSize (getChildElementIterator (aParent));
}
 
Example 18
Source File: CommonsArrayList.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Create a new array list that contains a subset of the provided iterable.
 * This method maps the elements before they are filtered.<br>
 * Note: this method is a static factory method because the compiler sometimes
 * cannot deduce between {@link Predicate} and {@link Function} and the
 * mapping case occurs more often.
 *
 * @param aValues
 *        The iterable from which the elements are copied from. May be
 *        <code>null</code>.
 * @param aMapper
 *        The mapping function to be executed for all provided elements. May
 *        not be <code>null</code>.
 * @param aFilter
 *        The filter to be applied on the mapped element to check if the
 *        element should be added or not.
 * @return The created array list. Never <code>null</code>.
 * @see #addAllMapped(Iterable, Function, Predicate)
 * @since 9.1.3
 * @param <SRCTYPE>
 *        source data type
 * @param <ELEMENTTYPE>
 *        final data type of the list
 */
@Nonnull
@ReturnsMutableCopy
public static <SRCTYPE, ELEMENTTYPE> CommonsArrayList <ELEMENTTYPE> createFiltered (@Nullable final Iterable <? extends SRCTYPE> aValues,
                                                                                    @Nonnull final Function <? super SRCTYPE, ? extends ELEMENTTYPE> aMapper,
                                                                                    @Nullable final Predicate <? super ELEMENTTYPE> aFilter)
{
  final CommonsArrayList <ELEMENTTYPE> ret = new CommonsArrayList <> (CollectionHelper.getSize (aValues));
  ret.addAllMapped (aValues, aMapper, aFilter);
  return ret;
}
 
Example 19
Source File: CommonsArrayList.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Create a new array list that contains a subset of the provided iterable.
 * This method filters the elements before they are mapped.<br>
 * Note: this method is a static factory method because the compiler sometimes
 * cannot deduce between {@link Predicate} and {@link Function} and the
 * mapping case occurs more often.
 *
 * @param aValues
 *        The iterable from which the elements are copied from. May be
 *        <code>null</code>.
 * @param aFilter
 *        The filter to be applied to check if the element should be added or
 *        not.
 * @param aMapper
 *        The mapping function to be executed for all provided elements. May
 *        not be <code>null</code>.
 * @return The created array list. Never <code>null</code>.
 * @see #addAllMapped(Iterable, Predicate, Function)
 * @param <SRCTYPE>
 *        source data type
 * @param <ELEMENTTYPE>
 *        final data type of the list
 */
@Nonnull
@ReturnsMutableCopy
public static <SRCTYPE, ELEMENTTYPE> CommonsArrayList <ELEMENTTYPE> createFiltered (@Nullable final Iterable <? extends SRCTYPE> aValues,
                                                                                    @Nullable final Predicate <? super SRCTYPE> aFilter,
                                                                                    @Nonnull final Function <? super SRCTYPE, ? extends ELEMENTTYPE> aMapper)
{
  final CommonsArrayList <ELEMENTTYPE> ret = new CommonsArrayList <> (CollectionHelper.getSize (aValues));
  ret.addAllMapped (aValues, aFilter, aMapper);
  return ret;
}
 
Example 20
Source File: CommonsArrayList.java    From ph-commons with Apache License 2.0 3 votes vote down vote up
/**
 * Create a new array list that contains the mapped elements of the provided
 * collection.
 *
 * @param aValues
 *        The collection to copy the initial capacity and the elements from.
 *        May be <code>null</code>.
 * @param aMapper
 *        The mapping function to be executed for all provided elements. May
 *        not be <code>null</code>.
 * @see #addAllMapped(Iterable, Function)
 * @param <SRCTYPE>
 *        source data type
 */
public <SRCTYPE> CommonsArrayList (@Nullable final Collection <? extends SRCTYPE> aValues,
                                   @Nonnull final Function <? super SRCTYPE, ? extends ELEMENTTYPE> aMapper)
{
  super (CollectionHelper.getSize (aValues));
  addAllMapped (aValues, aMapper);
}