
com.thesett.common.util.maps.CircularArrayMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common Show documentation
Show all versions of common Show documentation
My common library, a mixed bag of re-usable utility code.
The newest version!
/*
* Copyright The Sett Ltd, 2005 to 2014.
*
* 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 com.thesett.common.util.maps;
import java.util.Iterator;
import com.thesett.common.util.Countable;
import com.thesett.common.util.Sizeable;
/**
* CircularArrayMap is a map, that is keyed by integers. It places some approximate expectations of the life-cycle of
* keys used in the map, in order to provide a fast and reasonably compact data structure. The expectations are:
*
*
* - The integer keys will be generated sequentially and inserted into the map roughly in the order that they are
* generated. This means that new keys are added as a compact block of sequential keys.
* - The integer keys will be removed from the map roughly in the same order that they were inserted. This means that
* as keys are removed from the map, the removals will not create blocks of keys that are very sparse.
*
*
* These expectations on the keys may be met by a process that works over a set of data in an approximately forward
* only style. For example a process that takes data records and processes them though some sort of pipe-line, where
* temporary values must be calculated and stored against the records at each stage of the pipe-line, but that can be
* discarded later in the pipe-line, might be able to use this data structure efficiently.
*
*
CRC Card
* Responsibilities Collaborations
* Look up a value by a key.
* Store a value against a key.
*
*
* @author Rupert Smith
*/
public class CircularArrayMap© 2015 - 2025 Weber Informatics LLC | Privacy Policy