io.lacuna.bifurcan.ILinearizable Maven / Gradle / Ivy
package io.lacuna.bifurcan;
/**
* @author ztellman
*/
public interface ILinearizable {
/**
* This represents a data structure which can be made linear, which is equivalent to Clojure's transient
* data structures: only the most recent reference to the data structure should be used. If a linear data structure
* is modified (for instance, calling {@code addLast()} on an {@code IList}), we should only refer to the object returned
* by that method; anything else has undefined results.
*
* The term "linear", as used here, does not completely align with the formal definition of linear types
* as used in type theory. It is meant to describe the linear dataflow of the method calls, and as a converse to
* "forked" data structures.
*
* If the data structure is already linear, it will simply return itself.
*
* @return a linear form of this data structure
*/
T linear();
/**
*
* @return true, if the collection is linear
*/
boolean isLinear();
}