1using System.Collections;
2using System.Collections.Generic;
3using System.Threading.Tasks;
12 private readonly LinkedList<KeyValuePair<ISemanticElement, ISemanticTriple>> elements =
new LinkedList<KeyValuePair<ISemanticElement, ISemanticTriple>>();
15 private SortedDictionary<ISemanticElement, LinkedList<ISemanticTriple>> points =
null;
46 this.elements.AddLast(
new KeyValuePair<ISemanticElement, ISemanticTriple>(Point, Triple));
54 public void Add(IEnumerable<ISemanticTriple> Triples,
int ZIndex)
56 if (!(Triples is
null))
59 this.
Add(Triple[ZIndex], Triple);
69 return new TripleEnumerator(this.elements.GetEnumerator());
76 IEnumerator IEnumerable.GetEnumerator()
78 return new TripleEnumerator(this.elements.GetEnumerator());
81 private class TripleEnumerator : IEnumerator<ISemanticTriple>
83 private readonly IEnumerator<KeyValuePair<ISemanticElement, ISemanticTriple>> e;
85 public TripleEnumerator(IEnumerator<KeyValuePair<ISemanticElement, ISemanticTriple>> e)
90 public ISemanticTriple Current => this.e.Current.Value;
91 object IEnumerator.Current => this.e.Current.Value;
92 public void Dispose() => this.e.Dispose();
93 public bool MoveNext() => this.e.MoveNext();
94 public void Reset() => this.e.Reset();
106 if (!this.points.TryGetValue(X, out LinkedList<ISemanticTriple> Points))
109 return Task.FromResult<IEnumerable<ISemanticTriple>>(Points);
120 return Task.FromResult<IEnumerator<ISemanticElement>>(this.points.Keys.GetEnumerator());
123 private void CheckOrdered()
125 if (this.points is
null)
127 SortedDictionary<ISemanticElement, LinkedList<ISemanticTriple>> Ordered =
128 new SortedDictionary<ISemanticElement, LinkedList<ISemanticTriple>>();
130 LinkedList<ISemanticTriple> Last =
null;
132 foreach (KeyValuePair<ISemanticElement, ISemanticTriple> P
in this.elements)
134 if ((LastPoint is
null || !LastPoint.Equals(P.Key)) &&
135 !Ordered.TryGetValue(P.Key, out Last))
137 Last =
new LinkedList<ISemanticTriple>();
138 Ordered[P.Key] = Last;
141 Last.AddLast(P.Value);
144 this.points = Ordered;
Task< IEnumerator< ISemanticElement > > GetValueEnumerator()
Gets an enumerator of all values along the line.
IEnumerator< ISemanticTriple > GetEnumerator()
Gets an enumerator over all elements in plance.
void Add(ISemanticElement Point, ISemanticTriple Triple)
Adds an element to the line.
void Add(IEnumerable< ISemanticTriple > Triples, int ZIndex)
Adds a set of triples to the plane.
ISemanticElement Reference2
Line reference 2.
Task< IEnumerable< ISemanticTriple > > GetTriples(ISemanticElement X)
Gets available triples on the line, having a given coordinate.
InMemorySemanticLine(ISemanticElement Reference1, ISemanticElement Reference2)
In-memory semantic line.
ISemanticElement Reference1
Line reference 1.
Interface for semantic nodes.
Interface for semantic lines.
Interface for semantic triples.