Table of Contents

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 wrapper w = (Pair f), the pair p = (w t) and the outer (i: T p);
  • when another triplet took the outer (T p), a duplicate pair d = (p i) and the outer (i: T d);
  • an empty f or t is written as Nothing.

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>._constants
LinksDecoratorBase<TLinkAddress>._facade
LinksDecoratorBase<TLinkAddress>.Facade
LinksDecoratorBase<TLinkAddress>.Constants
LinksOperatorBase<TLinkAddress>._links
LinksOperatorBase<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

Triplets whose markers are the points named Pair and Nothing, created when missing.

public TripletsOverDoublets(INamedTypesLinks<TLinkAddress> links)

Parameters

links INamedTypesLinks<TLinkAddress>

Triplets whose markers are the points named Pair and Nothing, created when missing.

public TripletsOverDoublets(ILinks<TLinkAddress> links, INamedTypes<TLinkAddress> names)

Parameters

links ILinks<TLinkAddress>
names INamedTypes<TLinkAddress>
public TripletsOverDoublets(ILinks<TLinkAddress> links, INamedTypes<TLinkAddress> names, TripletMarkers<TLinkAddress> markers)

Parameters

links ILinks<TLinkAddress>
names INamedTypes<TLinkAddress>
markers TripletMarkers<TLinkAddress>

Fields

NothingMarkerName

The name of the marker point that stands for the empty part.

public const string NothingMarkerName = "Nothing"

Field Value

string

PairMarkerName

The name of the marker point of wrappers.

public const string PairMarkerName = "Pair"

Field Value

string

Properties

Markers

The markers of the encoding.

public TripletMarkers<TLinkAddress> Markers { get; }

Property Value

TripletMarkers<TLinkAddress>

Methods

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

link Link<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

query TripletQuery<TLinkAddress>

Returns

int

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

type TLinkAddress
from TLinkAddress
to TLinkAddress

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

address TLinkAddress

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

index TLinkAddress

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

id TLinkAddress

Returns

int

EachTriplet(TripletQuery<TLinkAddress>)

The triplets that match query, in the order of their addresses.

public virtual IReadOnlyList<Triplet<TLinkAddress>> EachTriplet(TripletQuery<TLinkAddress> query)

Parameters

query TripletQuery<TLinkAddress>

Returns

IReadOnlyList<Triplet<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

links ILinks<TLinkAddress>
names INamedTypes<TLinkAddress>

Returns

TripletMarkers<TLinkAddress>

GetByName(string)

public virtual TLinkAddress GetByName(string name)

Parameters

name string

Returns

TLinkAddress

GetName(TLinkAddress)

public virtual string? GetName(TLinkAddress link)

Parameters

link TLinkAddress

Returns

string

GetTriplet(TLinkAddress)

The triplet at index, null when it is not a triplet.

public virtual Triplet<TLinkAddress>? GetTriplet(TLinkAddress index)

Parameters

index TLinkAddress

Returns

Triplet<TLinkAddress>?

IsTriplet(TLinkAddress)

Whether index is a triplet.

public virtual bool IsTriplet(TLinkAddress index)

Parameters

index TLinkAddress

Returns

bool

RemoveName(TLinkAddress)

public virtual void RemoveName(TLinkAddress link)

Parameters

link TLinkAddress

RoleOf(TLinkAddress)

What the doublet id is in the encoding; null when it is missing.

public virtual DoubletRole? RoleOf(TLinkAddress id)

Parameters

id TLinkAddress

Returns

DoubletRole?

SetName(TLinkAddress, string)

public virtual TLinkAddress SetName(TLinkAddress link, string name)

Parameters

link TLinkAddress
name string

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

index TLinkAddress
type TLinkAddress
from TLinkAddress
to TLinkAddress

Returns

Triplet<TLinkAddress>