All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.grignaak.collections.CowMap Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.github.grignaak.collections;

import java.util.Map;

/**
 * A Copy-On-Write map (or a persistent data structure in the literature.
 *
 * 

A Copy-On-Write map has a cheap {@link #fork()} method which will return a new instance of the map, * but likely sharing the underlying data structure. Even when the data structure is shared, writes to either of the * forks are not reflected in the other fork. Forking can happen any number of times.

* *

The major purpose of a copy-on-write map is thread safety. A common idiom is to make updates to the collection in * one thread and then publish its fork to any number of reader threads. These reader threads can safely read their copy * of the fork while concurrent updates are happening.

*/ public interface CowMap extends Map, Forkable { /** * Create an independent copy of this map, where mutations on the returned instance do not affect this instance * and vice versa. Typically uses structural sharing on larger maps. */ CowMap fork(); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy