4using System.Threading.Tasks;
16 private SortedDictionary<ISemanticElement, InMemorySemanticLine> yPerX =
null;
17 private SortedDictionary<ISemanticElement, InMemorySemanticLine> xPerY =
null;
41 this.elements.Add(
new Tuple<ISemanticElement, ISemanticElement, ISemanticTriple>(X, Y, Triple));
52 public void Add(IEnumerable<ISemanticTriple> Triples,
int XIndex,
int YIndex)
54 if (!(Triples is
null))
57 this.
Add(Triple[XIndex], Triple[YIndex], Triple);
67 return new TripleEnumerator(this.elements.GetEnumerator());
74 IEnumerator IEnumerable.GetEnumerator()
76 return new TripleEnumerator(this.elements.GetEnumerator());
79 private class TripleEnumerator : IEnumerator<ISemanticTriple>
81 private readonly IEnumerator<Tuple<ISemanticElement, ISemanticElement, ISemanticTriple>> e;
83 public TripleEnumerator(IEnumerator<Tuple<ISemanticElement, ISemanticElement, ISemanticTriple>> e)
88 public ISemanticTriple Current => this.e.Current.Item3;
89 object IEnumerator.Current => this.e.Current.Item3;
90 public void Dispose() => this.e.Dispose();
91 public bool MoveNext() => this.e.MoveNext();
92 public void Reset() => this.e.Reset();
102 this.CheckXOrdered();
117 this.CheckYOrdered();
133 this.CheckXOrdered();
136 return Task.FromResult<IEnumerable<ISemanticTriple>>(
null);
138 return Line.GetTriples(Y);
147 this.CheckXOrdered();
149 return Task.FromResult<IEnumerator<ISemanticElement>>(this.yPerX.Keys.GetEnumerator());
158 this.CheckYOrdered();
160 return Task.FromResult<IEnumerator<ISemanticElement>>(this.xPerY.Keys.GetEnumerator());
163 private void CheckXOrdered()
165 if (this.yPerX is
null)
167 SortedDictionary<ISemanticElement, InMemorySemanticLine> Ordered =
168 new SortedDictionary<ISemanticElement, InMemorySemanticLine>();
172 foreach (Tuple<ISemanticElement, ISemanticElement, ISemanticTriple> P
in this.elements)
174 if ((LastPoint is
null || !LastPoint.Equals(P.Item1)) &&
175 !Ordered.TryGetValue(P.Item1, out Last))
178 Ordered[P.Item1] = Last;
181 Last.Add(P.Item2, P.Item3);
184 this.yPerX = Ordered;
188 private void CheckYOrdered()
190 if (this.xPerY is
null)
192 SortedDictionary<ISemanticElement, InMemorySemanticLine> Ordered =
193 new SortedDictionary<ISemanticElement, InMemorySemanticLine>();
194 ISemanticElement LastPoint =
null;
195 InMemorySemanticLine Last =
null;
197 foreach (Tuple<ISemanticElement, ISemanticElement, ISemanticTriple> P
in this.elements)
199 if ((LastPoint is
null || !LastPoint.Equals(P.Item2)) &&
200 !Ordered.TryGetValue(P.Item2, out Last))
202 Last =
new InMemorySemanticLine(P.Item2, P.Item1);
203 Ordered[P.Item2] = Last;
206 Last.Add(P.Item1, P.Item3);
209 this.xPerY = Ordered;
In-memory semantic plane.
Task< IEnumerable< ISemanticTriple > > GetTriplesByXAndY(ISemanticElement X, ISemanticElement Y)
Gets available triples in the plane, having a given X and Y-coordinate.
InMemorySemanticPlane(ISemanticElement Reference)
In-memory semantic plane.
ISemanticElement Reference
Plane reference.
IEnumerator< ISemanticTriple > GetEnumerator()
Gets an enumerator over all elements in plance.
Task< ISemanticLine > GetTriplesByX(ISemanticElement X)
Gets available triples in the plane, having a given X-coordinate.
Task< IEnumerator< ISemanticElement > > GetXAxisEnumerator()
Gets an enumerator of all elements along the X-axis.
Task< IEnumerator< ISemanticElement > > GetYAxisEnumerator()
Gets an enumerator of all elements along the Y-axis.
Task< ISemanticLine > GetTriplesByY(ISemanticElement Y)
Gets available triples in the plane, having a given Y-coordinate.
void Add(ISemanticElement X, ISemanticElement Y, ISemanticTriple Triple)
Adds an element to the plane.
void Add(IEnumerable< ISemanticTriple > Triples, int XIndex, int YIndex)
Adds a set of triples to the plane.
A chunked list is a linked list of chunks of objects of type T .
Interface for semantic nodes.
Interface for semantic lines.
Interface for semantic planes.
Interface for semantic triples.