/** * {@inheritDoc} * * @return {@code null} if there are no neighbors in the dataset, the majority vote of the * nearest neighbors otherwise and in the case of a tie, it returns the first result * which reached that number of votes * @throws PredictionFailedException if the {@code instanceParameter} was not a * {@link BaselearnerInstance} */ @Override public Double predict(IInstance<?, ?, ?> instanceParameter) throws PredictionFailedException { assertInstanceHasCorrectType(instanceParameter, BaselearnerInstance.class); BaselearnerInstance instance = (BaselearnerInstance) instanceParameter; List<VectorDistanceTuple<Double>> neighbors; neighbors = kdTree.getNearestNeighbours(new DenseDoubleVector(instance.getContextFeatureVector()), k); logger.debug(FOUND_NEIGHBORS, neighbors.toString()); Bag<Double> voteBag = new HashBag<>(); for (VectorDistanceTuple<Double> pair : neighbors) { Double vote = pair.getValue(); voteBag.add(vote); } logger.debug(VOTES, voteBag.toString()); Double result = null; int winningCount = 0; for (Double object : voteBag.uniqueSet()) { if (voteBag.getCount(object) > winningCount) { winningCount = voteBag.getCount(object); result = object; } } return result; }
/** * Remove any members of the bag that are not in the given bag, respecting * cardinality. * @see #retainAll(Collection) * * @param other the bag to retain * @return <code>true</code> if this call changed the collection */ boolean retainAll(final Bag<?> other) { boolean result = false; final Bag<E> excess = new HashBag<E>(); final Iterator<E> i = uniqueSet().iterator(); while (i.hasNext()) { final E current = i.next(); final int myCount = getCount(current); final int otherCount = other.getCount(current); if (1 <= otherCount && otherCount <= myCount) { excess.add(current, myCount - otherCount); } else { excess.add(current, myCount); } } if (!excess.isEmpty()) { result = removeAll(excess); } return result; }
/** * Compares this Bag to another. This Bag equals another Bag if it contains * the same number of occurrences of the same elements. * * @param object the Bag to compare to * @return true if equal */ @Override public boolean equals(final Object object) { if (object == this) { return true; } if (object instanceof Bag == false) { return false; } final Bag<?> other = (Bag<?>) object; if (other.size() != size()) { return false; } for (final E element : map.keySet()) { if (other.getCount(element) != getCount(element)) { return false; } } return true; }
public static void main(String[] args) { // Parse text to separate words String INPUT_TEXT = "Hello World! Hello All! Hi World!"; // Create Multiset Bag bag = SynchronizedSortedBag.synchronizedBag(new TreeBag(Arrays.asList(INPUT_TEXT.split(" ")))); // Print count words System.out.println(bag); // print [1:All!,2:Hello,1:Hi,2:World!]- in natural (alphabet) order // Print all unique words System.out.println(bag.uniqueSet()); // print [All!, Hello, Hi, World!]- in natural (alphabet) order // Print count occurrences of words System.out.println("Hello = " + bag.getCount("Hello")); // print 2 System.out.println("World = " + bag.getCount("World!")); // print 2 System.out.println("All = " + bag.getCount("All!")); // print 1 System.out.println("Hi = " + bag.getCount("Hi")); // print 1 System.out.println("Empty = " + bag.getCount("Empty")); // print 0 // Print count all words System.out.println(bag.size()); //print 6 // Print count unique words System.out.println(bag.uniqueSet().size()); //print 4 }
public static void main(String[] args) { // Parse text to separate words String INPUT_TEXT = "Hello World! Hello All! Hi World!"; // Create Multiset Bag bag = SynchronizedBag.synchronizedBag(new HashBag(Arrays.asList(INPUT_TEXT.split(" ")))); // Print count words System.out.println(bag); // print [1:Hi,2:Hello,2:World!,1:All!] - in random orders // Print all unique words System.out.println(bag.uniqueSet()); // print [Hi, Hello, World!, All!] - in random orders // Print count occurrences of words System.out.println("Hello = " + bag.getCount("Hello")); // print 2 System.out.println("World = " + bag.getCount("World!")); // print 2 System.out.println("All = " + bag.getCount("All!")); // print 1 System.out.println("Hi = " + bag.getCount("Hi")); // print 1 System.out.println("Empty = " + bag.getCount("Empty")); // print 0 // Print count all words System.out.println(bag.size()); //print 6 // Print count unique words System.out.println(bag.uniqueSet().size()); //print 4 }
public static void main(String[] args) { // Parse text to separate words String INPUT_TEXT = "Hello World! Hello All! Hi World!"; // Create Multiset Bag bag = new TreeBag(Arrays.asList(INPUT_TEXT.split(" "))); // Print count words System.out.println(bag); // print [1:All!,2:Hello,1:Hi,2:World!]- in natural (alphabet) order // Print all unique words System.out.println(bag.uniqueSet()); // print [All!, Hello, Hi, World!]- in natural (alphabet) order // Print count occurrences of words System.out.println("Hello = " + bag.getCount("Hello")); // print 2 System.out.println("World = " + bag.getCount("World!")); // print 2 System.out.println("All = " + bag.getCount("All!")); // print 1 System.out.println("Hi = " + bag.getCount("Hi")); // print 1 System.out.println("Empty = " + bag.getCount("Empty")); // print 0 // Print count all words System.out.println(bag.size()); //print 6 // Print count unique words System.out.println(bag.uniqueSet().size()); //print 4 }
public static void main(String[] args) { // Parse text to separate words String INPUT_TEXT = "Hello World! Hello All! Hi World!"; // Create Multiset Bag bag = new HashBag(Arrays.asList(INPUT_TEXT.split(" "))); // Print count words System.out.println(bag); // print [1:Hi,2:Hello,2:World!,1:All!] - in random orders // Print all unique words System.out.println(bag.uniqueSet()); // print [Hi, Hello, World!, All!] - in random orders // Print count occurrences of words System.out.println("Hello = " + bag.getCount("Hello")); // print 2 System.out.println("World = " + bag.getCount("World!")); // print 2 System.out.println("All = " + bag.getCount("All!")); // print 1 System.out.println("Hi = " + bag.getCount("Hi")); // print 1 System.out.println("Empty = " + bag.getCount("Empty")); // print 0 // Print count all words System.out.println(bag.size()); //print 6 // Print count unique words System.out.println(bag.uniqueSet().size()); //print 4 }
public static void main(String[] args) { // Разберем текст на слова String INPUT_TEXT = "Hello World! Hello All! Hi World!"; // Создаем Multiset Bag bag = SynchronizedSortedBag.synchronizedBag(new TreeBag(Arrays.asList(INPUT_TEXT.split(" ")))); // Выводим кол-вом вхождений слов System.out.println(bag); // напечатает [1:All!,2:Hello,1:Hi,2:World!]- в алфавитном порядке // Выводим все уникальные слова System.out.println(bag.uniqueSet()); // напечатает [All!, Hello, Hi, World!]- в алфавитном порядке // Выводим количество по каждому слову System.out.println("Hello = " + bag.getCount("Hello")); // напечатает 2 System.out.println("World = " + bag.getCount("World!")); // напечатает 2 System.out.println("All = " + bag.getCount("All!")); // напечатает 1 System.out.println("Hi = " + bag.getCount("Hi")); // напечатает 1 System.out.println("Empty = " + bag.getCount("Empty")); // напечатает 0 // Выводим общее количества всех слов в тексте System.out.println(bag.size()); //напечатает 6 // Выводим общее количество всех уникальных слов System.out.println(bag.uniqueSet().size()); //напечатает 4 }
public static void main(String[] args) { // Разберем текст на слова String INPUT_TEXT = "Hello World! Hello All! Hi World!"; // Создаем Multiset Bag bag = SynchronizedBag.synchronizedBag(new HashBag(Arrays.asList(INPUT_TEXT.split(" ")))); // Выводим кол-вом вхождений слов System.out.println(bag); // напечатает [1:Hi,2:Hello,2:World!,1:All!] - в произвольном порядке // Выводим все уникальные слова System.out.println(bag.uniqueSet()); // напечатает [Hi, Hello, World!, All!] - в произвольном порядке // Выводим количество по каждому слову System.out.println("Hello = " + bag.getCount("Hello")); // напечатает 2 System.out.println("World = " + bag.getCount("World!")); // напечатает 2 System.out.println("All = " + bag.getCount("All!")); // напечатает 1 System.out.println("Hi = " + bag.getCount("Hi")); // напечатает 1 System.out.println("Empty = " + bag.getCount("Empty")); // напечатает 0 // Выводим общее количества всех слов в тексте System.out.println(bag.size()); //напечатает 6 // Выводим общее количество всех уникальных слов System.out.println(bag.uniqueSet().size()); //напечатает 4 }
public static void main(String[] args) { // Разберем текст на слова String INPUT_TEXT = "Hello World! Hello All! Hi World!"; // Создаем Multiset Bag bag = new TreeBag(Arrays.asList(INPUT_TEXT.split(" "))); // Выводим кол-вом вхождений слов System.out.println(bag); // напечатает [1:All!,2:Hello,1:Hi,2:World!]- в алфавитном порядке // Выводим все уникальные слова System.out.println(bag.uniqueSet()); // напечатает [All!, Hello, Hi, World!]- в алфавитном порядке // Выводим количество по каждому слову System.out.println("Hello = " + bag.getCount("Hello")); // напечатает 2 System.out.println("World = " + bag.getCount("World!")); // напечатает 2 System.out.println("All = " + bag.getCount("All!")); // напечатает 1 System.out.println("Hi = " + bag.getCount("Hi")); // напечатает 1 System.out.println("Empty = " + bag.getCount("Empty")); // напечатает 0 // Выводим общее количества всех слов в тексте System.out.println(bag.size()); //напечатает 6 // Выводим общее количество всех уникальных слов System.out.println(bag.uniqueSet().size()); //напечатает 4 }
public static void main(String[] args) { // Разберем текст на слова String INPUT_TEXT = "Hello World! Hello All! Hi World!"; // Создаем Multiset Bag bag = new HashBag(Arrays.asList(INPUT_TEXT.split(" "))); // Выводим кол-вом вхождений слов System.out.println(bag); // напечатает [1:Hi,2:Hello,2:World!,1:All!] - в произвольном порядке // Выводим все уникальные слова System.out.println(bag.uniqueSet()); // напечатает [Hi, Hello, World!, All!] - в произвольном порядке // Выводим количество по каждому слову System.out.println("Hello = " + bag.getCount("Hello")); // напечатает 2 System.out.println("World = " + bag.getCount("World!")); // напечатает 2 System.out.println("All = " + bag.getCount("All!")); // напечатает 1 System.out.println("Hi = " + bag.getCount("Hi")); // напечатает 1 System.out.println("Empty = " + bag.getCount("Empty")); // напечатает 0 // Выводим общее количества всех слов в тексте System.out.println(bag.size()); //напечатает 6 // Выводим общее количество всех уникальных слов System.out.println(bag.uniqueSet().size()); //напечатает 4 }
/** * find category articles distribution, each output line like the following format: * [article count] \t [the category count which contains this specified article count] */ public void displayCategoryConceptDistribution() throws MissedException { Collection<String> categories = listNames(); Bag<Integer> catDistBag = new HashBag<>(); ProgressCounter counter = new ProgressCounter(); for (String c : categories) { counter.increment(); int articleCount = getConceptCount(getIdByName(c)); catDistBag.add(articleCount); } for (int key: catDistBag.uniqueSet()) { System.out.println(key + "\t" + catDistBag.getCount(key)); } }
/** * find category articles distribution, each output line like the following format: * [article count] \t [the category count which contains this specified article count] */ public void displayCategoryArticlesDistribution() throws MissedException { Collection<String> categories = listNames(); Bag<Integer> catDistBag = new HashBag<>(); ProgressCounter counter = new ProgressCounter(); for (String c : categories) { counter.increment(); int articleCount = getArticleCount(getIdByName(c)); catDistBag.add(articleCount); } for (int key: catDistBag.uniqueSet()) { System.out.println(key + "\t" + catDistBag.getCount(key)); } }
@SuppressWarnings(value = "unchecked") public void testBagEqualsHashBag_literalMutation1466() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagEqualsHashBag_literalMutation1466"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); final Bag<T> bag2 = new HashBag<T>(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5643,bag,5642,bag.equals(bag2)); bag.add(((T)("A"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5645,bag,5644,bag.equals(bag2)); bag2.add(((T)("A"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5647,bag,5646,bag.equals(bag2)); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); bag2.add(((T)("A"))); bag2.add(((T)("B"))); bag2.add(((T)("B"))); bag2.add(((T)("foo"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5649,bag,5648,bag.equals(bag2)); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") public void testBagIteratorFailDoubleRemove_literalMutation1503() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagIteratorFailDoubleRemove_literalMutation1503"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); bag.add(((T)("A"))); bag.add(((T)("foo"))); bag.add(((T)("B"))); final Iterator<T> it = bag.iterator(); it.next(); it.next(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5685,bag,5684,bag.size()); it.remove(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5687,bag,5686,bag.size()); try { it.remove(); } catch (final IllegalStateException ex) { } fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5689,bag,5688,bag.size()); it.next(); it.remove(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5691,bag,5690,bag.size()); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") public void testTransformedBag_literalMutation1616() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testTransformedBag_literalMutation1616"); final Bag<T> bag = org.apache.commons.collections4.bag.TransformedBag.transformingBag(new HashBag<T>(), ((org.apache.commons.collections4.Transformer<T, T>)(org.apache.commons.collections4.collection.TransformedCollectionTest.STRING_TO_INTEGER_TRANSFORMER))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5827,bag,5826,bag.size()); final Object[] els = new Object[]{ "1" , "foo" , "5" , "7" , "2" , "4" , "6" }; for (int i = 0 ; i < (els.length) ; i++) { bag.add(((T)(els[i]))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5828,(i + 1)); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5830,bag,5829,bag.size()); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5832,bag,5831,bag.contains(java.lang.Integer.valueOf(((java.lang.String)(els[i]))))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5834,bag,5833,bag.contains(els[i])); } fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5836,bag,5835,bag.remove(els[0])); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5838,bag,5837,bag.remove(java.lang.Integer.valueOf(((java.lang.String)(els[0]))))); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") @Test(timeout = 1000) public void testBagEquals_add1675() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagEquals_add1675"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); final Bag<T> bag2 = makeObject(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5659,bag,5658,bag.equals(bag2)); bag.add(((T)("A"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5661,bag,5660,bag.equals(bag2)); bag2.add(((T)("A"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5663,bag,5662,bag.equals(bag2)); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); bag.add(((T)("C"))); bag2.add(((T)("A"))); bag2.add(((T)("B"))); bag2.add(((T)("B"))); bag2.add(((T)("C"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5665,bag,5664,bag.equals(bag2)); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") public void testBagToArrayPopulate_literalMutation1584() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagToArrayPopulate_literalMutation1584"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); bag.add(((T)("A"))); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); final String[] array = bag.toArray(new String[0]); int a = 0; int b = 0; int c = 0; for (final String element : array) { a += element.equals("A") ? 1 : 0; b += element.equals("B") ? 1 : 0; c += element.equals("C") ? 2 : 0; } fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5764,a); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5765,b); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5766,c); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") @Test(timeout = 1000) public void testBagRetainAll_remove1340() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagRetainAll_remove1340"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); bag.add(((T)("A"))); bag.add(((T)("A"))); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); final List<java.lang.String> retains = new ArrayList<java.lang.String>(); retains.add("C"); bag.retainAll(retains); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5745,bag,5744,bag.size()); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") @Test(timeout = 1000) public void testBagEqualsHashBag_add1680() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagEqualsHashBag_add1680"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); final Bag<T> bag2 = new HashBag<T>(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5643,bag,5642,bag.equals(bag2)); bag.add(((T)("A"))); bag.add(((T)("A"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5645,bag,5644,bag.equals(bag2)); bag2.add(((T)("A"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5647,bag,5646,bag.equals(bag2)); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); bag2.add(((T)("A"))); bag2.add(((T)("B"))); bag2.add(((T)("B"))); bag2.add(((T)("C"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5649,bag,5648,bag.equals(bag2)); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") public void testBagToArrayPopulate_literalMutation1583() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagToArrayPopulate_literalMutation1583"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); bag.add(((T)("A"))); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); final String[] array = bag.toArray(new String[0]); int a = 0; int b = 0; int c = 0; for (final String element : array) { a += element.equals("A") ? 1 : 0; b += element.equals("B") ? 1 : 0; c += element.equals("foo") ? 1 : 0; } fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5764,a); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5765,b); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5766,c); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") public void testBagToArrayPopulate_literalMutation1569() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagToArrayPopulate_literalMutation1569"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); bag.add(((T)("A"))); bag.add(((T)("foo"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); final String[] array = bag.toArray(new String[0]); int a = 0; int b = 0; int c = 0; for (final String element : array) { a += element.equals("A") ? 1 : 0; b += element.equals("B") ? 1 : 0; c += element.equals("C") ? 1 : 0; } fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5764,a); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5765,b); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5766,c); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") @Test(timeout = 1000) public void testBagSize_remove1344() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagSize_remove1344"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5747,bag,5746,bag.size()); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5749,bag,5748,bag.size()); bag.add(((T)("A"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5751,bag,5750,bag.size()); bag.add(((T)("A"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5753,bag,5752,bag.size()); bag.add(((T)("B"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5755,bag,5754,bag.size()); bag.add(((T)("B"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5757,bag,5756,bag.size()); bag.remove("A", 2); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5759,bag,5758,bag.getCount("A")); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5761,bag,5760,bag.size()); bag.remove("B"); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5763,bag,5762,bag.size()); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") public void testBagToArray_literalMutation1556() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagToArray_literalMutation1556"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); bag.add(((T)("A"))); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); final Object[] array = bag.toArray(); int a = 0; int b = 1; int c = 0; for (final Object element : array) { a += element.equals("A") ? 1 : 0; b += element.equals("B") ? 1 : 0; c += element.equals("C") ? 1 : 0; } fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5767,a); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5768,b); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5769,c); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") @org.junit.Test(timeout = 1000) public void testlegalAddRemove_add1781() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testlegalAddRemove_add1781"); final Bag<T> bag = makeTestBag(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5808,bag,5807,bag.size()); final T[] els = ((T[])(new Object[]{ "1" , "3" , "5" , "7" , "2" , "4" , "1" })); for (int i = 0 ; i < (els.length) ; i++) { bag.add(els[i]); bag.add(els[i]); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5809,(i + 1)); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5811,bag,5810,bag.size()); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5813,bag,5812,bag.contains(els[i])); } Set<T> set = ((PredicatedBag<T>)(bag)).uniqueSet(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5815,set,5814,set.contains(els[0])); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5817,bag,5816,bag.remove(els[0])); set = ((PredicatedBag<T>)(bag)).uniqueSet(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5818,!(set.contains(els[0]))); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") public void testlegalAddRemove() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testlegalAddRemove"); final Bag<T> bag = makeTestBag(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5808,bag,5807,bag.size()); final T[] els = ((T[])(new Object[]{ "1" , "3" , "5" , "7" , "2" , "4" , "1" })); for (int i = 0 ; i < (els.length) ; i++) { bag.add(els[i]); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5809,(i + 1)); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5811,bag,5810,bag.size()); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5813,bag,5812,bag.contains(els[i])); } Set<T> set = ((PredicatedBag<T>)(bag)).uniqueSet(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5815,set,5814,set.contains(els[0])); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5817,bag,5816,bag.remove(els[0])); set = ((PredicatedBag<T>)(bag)).uniqueSet(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5818,!(set.contains(els[0]))); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") @Test(timeout = 1000) public void testBagEquals_remove1274() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagEquals_remove1274"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); final Bag<T> bag2 = makeObject(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5659,bag,5658,bag.equals(bag2)); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5661,bag,5660,bag.equals(bag2)); bag2.add(((T)("A"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5663,bag,5662,bag.equals(bag2)); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); bag2.add(((T)("A"))); bag2.add(((T)("B"))); bag2.add(((T)("B"))); bag2.add(((T)("C"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5665,bag,5664,bag.equals(bag2)); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") @Test(timeout = 1000) public void testBagRetainAll_remove1334() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagRetainAll_remove1334"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); bag.add(((T)("A"))); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); final List<java.lang.String> retains = new ArrayList<java.lang.String>(); retains.add("B"); retains.add("C"); bag.retainAll(retains); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5745,bag,5744,bag.size()); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") @Test(timeout = 1000) public void testBagEqualsHashBag_remove1281() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagEqualsHashBag_remove1281"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); final Bag<T> bag2 = new HashBag<T>(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5643,bag,5642,bag.equals(bag2)); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5645,bag,5644,bag.equals(bag2)); bag2.add(((T)("A"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5647,bag,5646,bag.equals(bag2)); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); bag2.add(((T)("A"))); bag2.add(((T)("B"))); bag2.add(((T)("B"))); bag2.add(((T)("C"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5649,bag,5648,bag.equals(bag2)); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") public void testlegalAddRemove_literalMutation1607() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testlegalAddRemove_literalMutation1607"); final Bag<T> bag = makeTestBag(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5808,bag,5807,bag.size()); final T[] els = ((T[])(new Object[]{ "1" , "3" , "5" , "7" , "2" , "4" , "foo" })); for (int i = 0 ; i < (els.length) ; i++) { bag.add(els[i]); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5809,(i + 1)); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5811,bag,5810,bag.size()); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5813,bag,5812,bag.contains(els[i])); } Set<T> set = ((PredicatedBag<T>)(bag)).uniqueSet(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5815,set,5814,set.contains(els[0])); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5817,bag,5816,bag.remove(els[0])); set = ((PredicatedBag<T>)(bag)).uniqueSet(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5818,!(set.contains(els[0]))); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") public void testBagRetainAll_literalMutation1533() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagRetainAll_literalMutation1533"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); bag.add(((T)("A"))); bag.add(((T)("foo"))); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); final List<java.lang.String> retains = new ArrayList<java.lang.String>(); retains.add("B"); retains.add("C"); bag.retainAll(retains); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5745,bag,5744,bag.size()); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") public void testBagIteratorFailDoubleRemove_literalMutation1502() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagIteratorFailDoubleRemove_literalMutation1502"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); bag.add(((T)("foo"))); bag.add(((T)("A"))); bag.add(((T)("B"))); final Iterator<T> it = bag.iterator(); it.next(); it.next(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5685,bag,5684,bag.size()); it.remove(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5687,bag,5686,bag.size()); try { it.remove(); } catch (final IllegalStateException ex) { } fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5689,bag,5688,bag.size()); it.next(); it.remove(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5691,bag,5690,bag.size()); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") @Test(timeout = 1000) public void testBagEquals_add1674() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagEquals_add1674"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); final Bag<T> bag2 = makeObject(); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5659,bag,5658,bag.equals(bag2)); bag.add(((T)("A"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5661,bag,5660,bag.equals(bag2)); bag2.add(((T)("A"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5663,bag,5662,bag.equals(bag2)); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); bag2.add(((T)("A"))); bag2.add(((T)("B"))); bag2.add(((T)("B"))); bag2.add(((T)("C"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5665,bag,5664,bag.equals(bag2)); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") public void testBagToArrayPopulate_literalMutation1573() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagToArrayPopulate_literalMutation1573"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); bag.add(((T)("A"))); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); final String[] array = bag.toArray(new String[1]); int a = 0; int b = 0; int c = 0; for (final String element : array) { a += element.equals("A") ? 1 : 0; b += element.equals("B") ? 1 : 0; c += element.equals("C") ? 1 : 0; } fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5764,a); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5765,b); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5766,c); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") @Test(timeout = 1000) public void testBagRemoveAll_remove1330() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagRemoveAll_remove1330"); if (!(isRemoveSupported())) { return ; } final Bag<T> bag = makeObject(); bag.add(((T)("A")), 2); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5721,bag,5720,bag.getCount("A")); bag.add(((T)("B"))); bag.add(((T)("C"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5723,bag,5722,bag.size()); final List<java.lang.String> delete = new ArrayList<java.lang.String>(); delete.add("B"); bag.removeAll(delete); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5725,bag,5724,bag.getCount("A")); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5727,bag,5726,bag.getCount("B")); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5729,bag,5728,bag.getCount("C")); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5731,bag,5730,bag.size()); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") public void testBagRetainAll_literalMutation1532() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagRetainAll_literalMutation1532"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); bag.add(((T)("foo"))); bag.add(((T)("A"))); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); final List<java.lang.String> retains = new ArrayList<java.lang.String>(); retains.add("B"); retains.add("C"); bag.retainAll(retains); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5745,bag,5744,bag.size()); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") @Test(timeout = 1000) public void testBagAdd_add1654() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagAdd_add1654"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); bag.add(((T)("A"))); bag.add(((T)("A"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5565,bag,5564,bag.contains("A")); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5567,bag,5566,bag.getCount("A")); bag.add(((T)("A"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5569,bag,5568,bag.contains("A")); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5571,bag,5570,bag.getCount("A")); bag.add(((T)("B"))); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5573,bag,5572,bag.contains("A")); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5575,bag,5574,bag.contains("B")); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }
@SuppressWarnings(value = "unchecked") @Test(timeout = 1000) public void testBagRetainAll_remove1341() { fr.inria.diversify.testamplification.logger.Logger.writeTestStart(Thread.currentThread(),this, "testBagRetainAll_remove1341"); if (!(isAddSupported())) { return ; } final Bag<T> bag = makeObject(); bag.add(((T)("A"))); bag.add(((T)("A"))); bag.add(((T)("A"))); bag.add(((T)("B"))); bag.add(((T)("B"))); bag.add(((T)("C"))); final List<java.lang.String> retains = new ArrayList<java.lang.String>(); retains.add("B"); retains.add("C"); fr.inria.diversify.testamplification.logger.Logger.logAssertArgument(Thread.currentThread(),5745,bag,5744,bag.size()); fr.inria.diversify.testamplification.logger.Logger.writeTestFinish(Thread.currentThread()); }