The Flyweight of Sparse Glyphs
Share matrix states to support vast quantities of sparse glyphs efficiently.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Flyweight
ARCANUM SCHOOL: Transmutation // Efficiency
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// MATLAB PATTERN //
classdef GlyphFlyweightFactory < handle
properties
Cache
end
methods
function obj = GlyphFlyweightFactory()
obj.Cache = containers.Map();
end
function glyph = getGlyph(obj, symbol)
if ~isKey(obj.Cache, symbol)
obj.Cache(symbol) = SparseGlyph(symbol);
end
glyph = obj.Cache(symbol);
end
end
end
Flyweight
Memory is a finite resource even in the astral plane; sparse representations and shared instances save the realm.
Runic Tags:
#flyweight
#sparse
#glyphs