Interface MemoryModel

All Known Implementing Classes:
AbstractMemoryModel, BufferMemoryModel, CombinedMemoryModel, LargeMemoryModel, SignalMemoryModel, SimpleMemoryModel

public interface MemoryModel

Virtual memory model: implementations of this abstract factory is the main way of creating new AlgART arrays.

Virtual memory model is an abstraction describing how the array elements are stored in memory. For example, the simplest memory model is SimpleMemoryModel, that use Java arrays for storing array elements (alike java.util.ArrayList). Another example is LargeMemoryModel: memory model based on direct byte buffers created via java.nio.ByteBuffer.allocateDirect method or via mapping disk files.

The arrays, created with help of different memory models, implement identical interfaces and usually look absolutely identical for an application, but may work with differente performance. For example, if you need an array of simple object elements (as "circles" or "points"), you may choose CombinedMemoryModel memory model to save memory and provide quick memory allocation, or SimpleMemoryModel to provide maximal performance while accessing array elements.

Some arrays may have no well-defined memory model, but be created without any factories. The simples example is a constant arrays created by methods Arrays.nByteCopies(long, byte), Arrays.nCharCopies(long, char), etc.

Objects implementing this interface may be not immutable, though all its implementations in this package are immutable. But there is a guarantee that any memory model is thread-safe and can be used simultaneously in several threads. (In other words, if another package implements a custom mutable memory model, it must be internally synchronized.)

Author:
Daniel Alievsky