Java Code Examples for org.apache.commons.collections4.queue.CircularFifoQueue#clear()

The following examples show how to use org.apache.commons.collections4.queue.CircularFifoQueue#clear() . 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: JsonDataGeneratorImpl.java    From json-data-generator with Apache License 2.0 5 votes vote down vote up
private void setQueueCharacters(final CircularFifoQueue<Character> characters,
    final String string) {
    characters.clear();
    char[] charArray = string.toCharArray();
    for (int i = 0; i < charArray.length; i++) {
        characters.add(charArray[i]);
    }
}
 
Example 2
Source File: CircularFifoQueueUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenFullQueue_whenClearQueue_getIsEmpty() {
    CircularFifoQueue<String> colors = new CircularFifoQueue<>(5);
    colors.add("Red");
    colors.add("Blue");
    colors.add("Green");
    colors.offer("White");
    colors.offer("Black");

    colors.clear();

    Assert.assertEquals(true, colors.isEmpty());
}