Class TripletsOverDoublets<TLinkAddress>
- Namespace
- Foundation.Data.Doublets.Cli
- Assembly
- Foundation.Data.Doublets.Cli.dll
A decorator that stores triplets (index: type from to) in the doublets
of the links it wraps (issue #151). The encoding keeps the convention of the
type hierarchy of issue #148, the type of a link is its source:
- a node
(i: T 0 0)is the doublet(i: T i); (i: T f t)is the wrapperw = (Pair f), the pairp = (w t)and the outer(i: T p);- when another triplet took the outer
(T p), a duplicate paird = (p i)and the outer(i: T d); - an empty
fortis written asNothing.
The Rust counterpart is link_cli::TripletsOverDoublets;
docs/TRIPLETS.md compares the encoding with the alternatives.
public class TripletsOverDoublets<TLinkAddress> : LinksDecoratorBase<TLinkAddress>, ITriplets<TLinkAddress>, INamedTypesLinks<TLinkAddress>, ILinks<TLinkAddress>, ILinks<TLinkAddress, LinksConstants<TLinkAddress>>, INamedTypes<TLinkAddress> where TLinkAddress : struct, IUnsignedNumber<TLinkAddress>, IComparisonOperators<TLinkAddress, TLinkAddress, bool>, IShiftOperators<TLinkAddress, int, TLinkAddress>, IBitwiseOperators<TLinkAddress, TLinkAddress, TLinkAddress>, IMinMaxValue<TLinkAddress>
Type Parameters
TLinkAddress
- Inheritance
-
LinksOperatorBase<TLinkAddress>LinksDecoratorBase<TLinkAddress>TripletsOverDoublets<TLinkAddress>
- Implements
-
ITriplets<TLinkAddress>INamedTypesLinks<TLinkAddress>ILinks<TLinkAddress>ILinks<TLinkAddress, LinksConstants<TLinkAddress>>INamedTypes<TLinkAddress>
- Inherited Members
-
LinksDecoratorBase<TLinkAddress>._constantsLinksDecoratorBase<TLinkAddress>._facadeLinksDecoratorBase<TLinkAddress>.FacadeLinksDecoratorBase<TLinkAddress>.ConstantsLinksOperatorBase<TLinkAddress>._linksLinksOperatorBase<TLinkAddress>.Links
- Extension Methods
Remarks
Reads go to the decorated links; writes go through this decorator, so a derived decorator that checks writes sees every doublet the encoding writes. The class is not sealed and every member is virtual.
Constructors
TripletsOverDoublets(INamedTypesLinks<TLinkAddress>)
Triplets whose markers are the points named Pair and Nothing, created when missing.
public TripletsOverDoublets(INamedTypesLinks<TLinkAddress> links)
Parameters
linksINamedTypesLinks<TLinkAddress>
TripletsOverDoublets(ILinks<TLinkAddress>, INamedTypes<TLinkAddress>)
Triplets whose markers are the points named Pair and Nothing, created when missing.
public TripletsOverDoublets(ILinks<TLinkAddress> links, INamedTypes<TLinkAddress> names)
Parameters
linksILinks<TLinkAddress>namesINamedTypes<TLinkAddress>
TripletsOverDoublets(ILinks<TLinkAddress>, INamedTypes<TLinkAddress>, TripletMarkers<TLinkAddress>)
public TripletsOverDoublets(ILinks<TLinkAddress> links, INamedTypes<TLinkAddress> names, TripletMarkers<TLinkAddress> markers)
Parameters
linksILinks<TLinkAddress>namesINamedTypes<TLinkAddress>markersTripletMarkers<TLinkAddress>
Fields
NothingMarkerName
The name of the marker point that stands for the empty part.
public const string NothingMarkerName = "Nothing"
Field Value
PairMarkerName
The name of the marker point of wrappers.
public const string PairMarkerName = "Pair"
Field Value
Properties
Markers
The markers of the encoding.
public TripletMarkers<TLinkAddress> Markers { get; }
Property Value
- TripletMarkers<TLinkAddress>
Methods
Classify(Link<TLinkAddress>)
What link is in the encoding, and the triplet when it is one.
protected virtual (DoubletRole Role, Triplet<TLinkAddress> Triplet) Classify(Link<TLinkAddress> link)
Parameters
linkLink<TLinkAddress>
Returns
- (DoubletRole Role, Triplet<TLinkAddress> Triplet)
CountTriplets(TripletQuery<TLinkAddress>)
The number of triplets that match query.
public virtual int CountTriplets(TripletQuery<TLinkAddress> query)
Parameters
queryTripletQuery<TLinkAddress>
Returns
CreateTriplet(TLinkAddress, TLinkAddress, TLinkAddress)
Creates (i: type from to) and returns i. type
must be a triplet; from and to triplets or the null link.
public virtual TLinkAddress CreateTriplet(TLinkAddress type, TLinkAddress from, TLinkAddress to)
Parameters
typeTLinkAddressfromTLinkAddresstoTLinkAddress
Returns
- TLinkAddress
CreateTripletPoint()
Creates a triplet (i: i 0 0) that is its own type.
public virtual TLinkAddress CreateTripletPoint()
Returns
- TLinkAddress
CreateTripletPointAt(TLinkAddress)
Makes the free address address a triplet (address: address 0 0) that is its own type.
public virtual void CreateTripletPointAt(TLinkAddress address)
Parameters
addressTLinkAddress
DeleteTriplet(TLinkAddress)
Deletes the triplet at index and every triplet that uses
a deleted one as its type, from or to; returns them all, index first.
public virtual IReadOnlyList<Triplet<TLinkAddress>> DeleteTriplet(TLinkAddress index)
Parameters
indexTLinkAddress
Returns
- IReadOnlyList<Triplet<TLinkAddress>>
DoubletUsages(TLinkAddress)
How many other doublets use the doublet id as their source or target.
public virtual int DoubletUsages(TLinkAddress id)
Parameters
idTLinkAddress
Returns
EachTriplet(TripletQuery<TLinkAddress>)
The triplets that match query, in the order of their addresses.
public virtual IReadOnlyList<Triplet<TLinkAddress>> EachTriplet(TripletQuery<TLinkAddress> query)
Parameters
queryTripletQuery<TLinkAddress>
Returns
- IReadOnlyList<Triplet<TLinkAddress>>
EnsureMarkers(ILinks<TLinkAddress>, INamedTypes<TLinkAddress>)
The points named Pair and Nothing, each created as a point and named when missing.
public static TripletMarkers<TLinkAddress> EnsureMarkers(ILinks<TLinkAddress> links, INamedTypes<TLinkAddress> names)
Parameters
linksILinks<TLinkAddress>namesINamedTypes<TLinkAddress>
Returns
- TripletMarkers<TLinkAddress>
GetByName(string)
public virtual TLinkAddress GetByName(string name)
Parameters
namestring
Returns
- TLinkAddress
GetName(TLinkAddress)
public virtual string? GetName(TLinkAddress link)
Parameters
linkTLinkAddress
Returns
GetTriplet(TLinkAddress)
The triplet at index, null when it is not a triplet.
public virtual Triplet<TLinkAddress>? GetTriplet(TLinkAddress index)
Parameters
indexTLinkAddress
Returns
- Triplet<TLinkAddress>?
IsTriplet(TLinkAddress)
Whether index is a triplet.
public virtual bool IsTriplet(TLinkAddress index)
Parameters
indexTLinkAddress
Returns
RemoveName(TLinkAddress)
public virtual void RemoveName(TLinkAddress link)
Parameters
linkTLinkAddress
RoleOf(TLinkAddress)
What the doublet id is in the encoding; null when it is missing.
public virtual DoubletRole? RoleOf(TLinkAddress id)
Parameters
idTLinkAddress
Returns
SetName(TLinkAddress, string)
public virtual TLinkAddress SetName(TLinkAddress link, string name)
Parameters
linkTLinkAddressnamestring
Returns
- TLinkAddress
UpdateTriplet(TLinkAddress, TLinkAddress, TLinkAddress, TLinkAddress)
Makes the triplet at index (index: type from to),
keeping its address, and returns the triplet as it was. The pair it no
longer uses is collected when nothing else uses it.
public virtual Triplet<TLinkAddress> UpdateTriplet(TLinkAddress index, TLinkAddress type, TLinkAddress from, TLinkAddress to)
Parameters
indexTLinkAddresstypeTLinkAddressfromTLinkAddresstoTLinkAddress
Returns
- Triplet<TLinkAddress>