io.github.resilience4j.circularbuffer.CircularFifoBuffer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of resilience4j-circularbuffer Show documentation
Show all versions of resilience4j-circularbuffer Show documentation
Resilience4j is a lightweight, easy-to-use fault tolerance library designed for Java8 and functional programming
/*
*
* Copyright 2016 Robert Winkler and Bohdan Storozhuk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/
package io.github.resilience4j.circularbuffer;
import io.vavr.collection.List;
import io.vavr.control.Option;
/**
* A {@link CircularFifoBuffer} is a first in first out buffer with a fixed size that replaces its
* oldest element if full. {@link CircularFifoBuffer} does NOT accept null elements.
**/
public interface CircularFifoBuffer {
/**
* Returns the number of elements in this {@link CircularFifoBuffer}.
*
* @return the number of elements in this {@link CircularFifoBuffer}
*/
int size();
/**
* Returns true
if this {@link CircularFifoBuffer} contains no elements.
*
* @return true
if this {@link CircularFifoBuffer} contains no elements
*/
boolean isEmpty();
/**
* Returns true
if this {@link CircularFifoBuffer} is full.
*
* @return true
if this {@link CircularFifoBuffer} is full
*/
boolean isFull();
/**
* Returns a list containing all of the elements in this {@link CircularFifoBuffer}. The
* elements are copied into an array.
*
* @return a list containing all of the elements in this {@link CircularFifoBuffer}
*/
List toList();
/**
* Adds element to the {@link CircularFifoBuffer} and overwrites the oldest element when {@link
* CircularFifoBuffer#isFull}.
*
* @param element to add
* @throws NullPointerException if the specified element is null
*/
void add(T element);
/**
* Retrieves and removes the head of this queue, or returns {@link Option.None} if this queue is
* empty.
*
* @return the head of this queue, or {@link Option.None} if this queue is empty
*/
Option take();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy