Package org.apache.commons.collections4.bag

Examples of org.apache.commons.collections4.bag.HashBag


        assertEquals(0, CollectionUtils.cardinality("B", set));
        assertEquals(1, CollectionUtils.cardinality("C", set));
        assertEquals(0, CollectionUtils.cardinality("D", set));
        assertEquals(1, CollectionUtils.cardinality("E", set));

        Bag bag = new HashBag();
        bag.add("A", 3);
        bag.add("C");
        bag.add("E");
        bag.add("E");
        assertEquals(3, CollectionUtils.cardinality("A", bag));
        assertEquals(0, CollectionUtils.cardinality("B", bag));
        assertEquals(1, CollectionUtils.cardinality("C", bag));
        assertEquals(0, CollectionUtils.cardinality("D", bag));
        assertEquals(2, CollectionUtils.cardinality("E", bag));
View Full Code Here


        // Enumeration, non-existent entry -- "dead" enumerator returned
        test = CollectionUtils.index(enumeration, 3);
        assertTrue(test.equals(enumeration) && !enumeration.hasMoreElements());
       
        // Collection, entry exists
        Bag bag = new HashBag();
        bag.add("element", 1);
        test = CollectionUtils.index(bag, 0);
        assertTrue(test.equals("element"));
       
        // Collection, non-existent entry -- "dead" iterator returned
        test = CollectionUtils.index(bag, 2);
View Full Code Here

            assertTrue(!enumeration.hasMoreElements());
        }

        {
            // Collection, entry exists
            Bag bag = new HashBag();
            bag.add("element", 1);
            assertEquals("element", CollectionUtils.get(bag, 0));
       
            // Collection, non-existent entry
            try {
                CollectionUtils.get(bag, 1);
View Full Code Here

  }

  //loads the files and removes words which occur less than 5 tims
  public void loadProgram() throws FileNotFoundException
  {
    Bag wordBag = new HashBag();

    //Load all the medical files in the directory
    File[] fileList = new File(recordsDir).listFiles();
    for (int i = 0; i<fileList.length; i++) {
      loadFile(fileList[i].toString(), wordBag);
    }

    //dump bag into frequent who appear in 5 or more medical records
    for (Object obj : wordBag.uniqueSet()) {
      if (wordBag.getCount(obj) > 4){
        frequent.add((String)obj);
      }
    }

  }
View Full Code Here

     * @param object  the input object
     * @return never
     * @throws FunctorException always
     */
    public boolean evaluate(final T object) {
        throw new FunctorException("ExceptionPredicate invoked");
    }
View Full Code Here

     *
     * @return never
     * @throws FunctorException always
     */
    public T create() {
        throw new FunctorException("ExceptionFactory invoked");
    }
View Full Code Here

        public T create() {
            try {
                return clazz.newInstance();
            } catch (final Exception ex) {
                throw new FunctorException("Cannot instantiate class: " + clazz, ex);
            }
        }
View Full Code Here

        try {
            final Class<?> cls = input.getClass();
            final Method method = cls.getMethod(iMethodName, iParamTypes);
            return (O) method.invoke(input, iArgs);
        } catch (final NoSuchMethodException ex) {
            throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" +
                                       input.getClass() + "' does not exist");
        } catch (final IllegalAccessException ex) {
            throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" +
                                       input.getClass() + "' cannot be accessed");
        } catch (final InvocationTargetException ex) {
            throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" +
                                       input.getClass() + "' threw an exception", ex);
        }
    }
View Full Code Here

     * @param input  the input object to transform
     * @return never
     * @throws FunctorException always
     */
    public O transform(final I input) {
        throw new FunctorException("ExceptionTransformer invoked");
    }
View Full Code Here

     *
     * @param input  the input object
     * @throws FunctorException always
     */
    public void execute(final E input) {
        throw new FunctorException("ExceptionClosure invoked");
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.collections4.bag.HashBag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.