Java Code Examples for org.apache.commons.collections4.queue.CircularFifoQueue#add()
The following examples show how to use
org.apache.commons.collections4.queue.CircularFifoQueue#add() .
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: NodeClusterCoordinator.java From localization_nifi with Apache License 2.0 | 5 votes |
private void addNodeEvent(final NodeIdentifier nodeId, final Severity severity, final String message) { final NodeEvent event = new Event(nodeId.toString(), message, severity); final CircularFifoQueue<NodeEvent> eventQueue = nodeEvents.computeIfAbsent(nodeId, id -> new CircularFifoQueue<>()); synchronized (eventQueue) { eventQueue.add(event); } }
Example 2
Source File: JsonDataGeneratorImpl.java From json-data-generator with Apache License 2.0 | 5 votes |
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 3
Source File: RateLimitTest.java From FlowSpaceFirewall with Apache License 2.0 | 5 votes |
@Test public void testRateLimitFast(){ RateTracker tracker = new RateTracker(2000,10000); CircularFifoQueue<Date> fifo = tracker.getFifo(); Date now = new Date(); for(int i =0; i< 1000;i++){ fifo.add(now); } assertTrue("Tracker Rate is " + tracker.getRate(), tracker.getRate() == (1000 * 1000)); }
Example 4
Source File: NodeClusterCoordinator.java From nifi with Apache License 2.0 | 5 votes |
private void addNodeEvent(final NodeIdentifier nodeId, final Severity severity, final String message) { final NodeEvent event = new Event(nodeId.toString(), message, severity); final CircularFifoQueue<NodeEvent> eventQueue = nodeEvents.computeIfAbsent(nodeId.getId(), id -> new CircularFifoQueue<>()); synchronized (eventQueue) { eventQueue.add(event); } }
Example 5
Source File: CircularFifoQueueUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenAddElements_whenUsingIntConstructor_correctSizeQueue() { CircularFifoQueue<String> colors = new CircularFifoQueue<>(5); colors.add("Red"); colors.add("Blue"); colors.add("Green"); colors.offer("White"); colors.offer("Black"); Assert.assertEquals(FIXED_SIZE, colors.maxSize()); }
Example 6
Source File: CircularFifoQueueUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenAddElements_whenGetElement_correctElement() { CircularFifoQueue<String> colors = new CircularFifoQueue<>(5); colors.add("Red"); colors.add("Blue"); colors.add("Green"); colors.offer("White"); colors.offer("Black"); Assert.assertEquals(TEST_COLOR_BY_INDEX, colors.get(1)); }
Example 7
Source File: CircularFifoQueueUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenAddElements_whenPollElement_correctElement() { CircularFifoQueue<String> colors = new CircularFifoQueue<>(5); colors.add("Red"); colors.add("Blue"); colors.add("Green"); colors.offer("White"); colors.offer("Black"); Assert.assertEquals(TEST_COLOR, colors.poll()); }
Example 8
Source File: CircularFifoQueueUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenAddElements_whenPeekQueue_correctElement() { CircularFifoQueue<String> colors = new CircularFifoQueue<>(5); colors.add("Red"); colors.add("Blue"); colors.add("Green"); colors.offer("White"); colors.offer("Black"); Assert.assertEquals(TEST_COLOR, colors.peek()); }
Example 9
Source File: CircularFifoQueueUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenAddElements_whenElementQueue_correctElement() { CircularFifoQueue<String> colors = new CircularFifoQueue<>(5); colors.add("Red"); colors.add("Blue"); colors.add("Green"); colors.offer("White"); colors.offer("Black"); Assert.assertEquals(TEST_COLOR, colors.element()); }
Example 10
Source File: CircularFifoQueueUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenAddElements_whenRemoveElement_correctElement() { CircularFifoQueue<String> colors = new CircularFifoQueue<>(5); colors.add("Red"); colors.add("Blue"); colors.add("Green"); colors.offer("White"); colors.offer("Black"); Assert.assertEquals(TEST_COLOR, colors.remove()); }
Example 11
Source File: CircularFifoQueueUnitTest.java From tutorials with MIT License | 5 votes |
@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()); }
Example 12
Source File: CircularFifoQueueUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenFullQueue_whenCheckFull_getIsFull() { CircularFifoQueue<String> colors = new CircularFifoQueue<>(5); colors.add("Red"); colors.add("Blue"); colors.add("Green"); colors.offer("White"); colors.offer("Black"); Assert.assertEquals(false, colors.isFull()); }
Example 13
Source File: CircularFifoQueueUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenFullQueue_whenAddMoreElements_getIsAtFullCapacity() { CircularFifoQueue<String> colors = new CircularFifoQueue<>(5); colors.add("Red"); colors.add("Blue"); colors.add("Green"); colors.offer("White"); colors.offer("Black"); colors.add("Orange"); colors.add("Violet"); colors.add("Pink"); Assert.assertEquals(true, colors.isAtFullCapacity()); }