Skip to content

Commit 8511b50

Browse files
Copilotpetesramek
andauthored
docs: update README examples to use new ValuesPerItem and states[] pattern
Agent-Logs-Url: https://github.com/petesramek/polyline-algorithm-csharp/sessions/8a3b65fb-20f2-40d5-a3cc-0ea2638e1e94 Co-authored-by: petesramek <2333452+petesramek@users.noreply.github.com>
1 parent 621d6e5 commit 8511b50

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

src/PolylineAlgorithm/README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@ using PolylineAlgorithm.Abstraction;
4141
using PolylineAlgorithm.Internal;
4242

4343
public sealed class MyPolylineEncoder : AbstractPolylineEncoder<(double Latitude, double Longitude), string> {
44-
private PolylineValueState _latitudeState;
45-
private PolylineValueState _longitudeState;
44+
protected override int ValuesPerItem => 2;
4645

47-
protected override void Write((double Latitude, double Longitude) item, ref PolylineWriter writer) {
48-
writer.Write(item.Latitude, ref _latitudeState); // field 0
49-
writer.Write(item.Longitude, ref _longitudeState); // field 1
46+
protected override void Write((double Latitude, double Longitude) item, ref PolylineWriter writer, PolylineValueState[] states) {
47+
writer.Write(item.Latitude, ref states[0]); // field 0
48+
writer.Write(item.Longitude, ref states[1]); // field 1
5049
}
5150
protected override string CreatePolyline(ReadOnlySpan<char> polyline) => polyline.ToString();
5251
}
@@ -78,11 +77,10 @@ using PolylineAlgorithm.Abstraction;
7877
using PolylineAlgorithm.Internal;
7978

8079
public sealed class MyPolylineDecoder : AbstractPolylineDecoder<string, (double Latitude, double Longitude)> {
81-
private PolylineValueState _latitudeState;
82-
private PolylineValueState _longitudeState;
80+
protected override int ValuesPerItem => 2;
8381

84-
protected override (double Latitude, double Longitude) Read(PolylineReader reader) =>
85-
(reader.Read(ref _latitudeState), reader.Read(ref _longitudeState)); // field 0, field 1
82+
protected override (double Latitude, double Longitude) Read(PolylineReader reader, PolylineValueState[] states) =>
83+
(reader.Read(ref states[0]), reader.Read(ref states[1])); // field 0, field 1
8684
protected override ReadOnlyMemory<char> GetReadOnlyMemory(in string polyline) => polyline.AsMemory();
8785
}
8886
```

0 commit comments

Comments
 (0)