Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Removed Position.Get #2045

Merged
merged 1 commit into from
Jan 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,16 @@ public override string ToString()

}
}

public static class PositionExtensions
{
public static (T segment, int index) Get<T>(this Position position)
{
var segment = position.Segment;
var index = position.Index;
return ((T)segment, index);
}
}
}


9 changes: 0 additions & 9 deletions src/System.Buffers.Primitives/System/Collections/Position.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Buffers;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace System.Collections.Sequences
Expand All @@ -30,13 +28,6 @@ public Position(object segment)

public static explicit operator int(Position position) => position._index;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public (T segment, int index) Get<T>()
{
var segment = _segment == null ? default : (T)_segment;
return (segment, _index);
}

public static bool operator ==(Position left, Position right) => left._index == right._index && left._segment == right._segment;
public static bool operator !=(Position left, Position right) => left._index != right._index || left._segment != right._segment;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,14 @@ public Position Seek(Position origin, long offset)
return new Position(node, 0);
}
}

public static class PositionExtensions
{
public static (T segment, int index) Get<T>(this Position position)
{
var segment = position.Segment;
var index = position.Index;
return ((T)segment, index);
}
}
}