Skip to content

Commit

Permalink
Used readonly span in the params in the queue types.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Nov 16, 2024
1 parent 6eebe11 commit f4a2811
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
7 changes: 4 additions & 3 deletions FinModelUtility/Fin/Fin/src/data/queues/DistinctQueue.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;

namespace fin.data.queues;
Expand All @@ -9,7 +10,7 @@ public class DistinctQueue<T> : IFinQueue<T> {

public DistinctQueue() { }

public DistinctQueue(T first, params T[] rest)
public DistinctQueue(T first, params ReadOnlySpan<T> rest)
=> this.Enqueue(first, rest);

public DistinctQueue(IEnumerable<T> values)
Expand All @@ -22,7 +23,7 @@ public void Clear() {
this.impl_.Clear();
}

public void Enqueue(T first, params T[] rest) {
public void Enqueue(T first, params ReadOnlySpan<T> rest) {
this.EnqueueImpl_(first);
foreach (var value in rest) {
this.EnqueueImpl_(value);
Expand Down
7 changes: 4 additions & 3 deletions FinModelUtility/Fin/Fin/src/data/queues/FinQueue.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;

namespace fin.data.queues;
Expand All @@ -8,7 +9,7 @@ public class FinQueue<T> : IFinQueue<T> {

public FinQueue() { }

public FinQueue(T first, params T[] rest)
public FinQueue(T first, params ReadOnlySpan<T> rest)
=> this.Enqueue(first, rest);

public FinQueue(IEnumerable<T> values)
Expand All @@ -18,7 +19,7 @@ public FinQueue(IEnumerable<T> values)

public void Clear() => this.impl_.Clear();

public void Enqueue(T first, params T[] rest) {
public void Enqueue(T first, params ReadOnlySpan<T> rest) {
this.impl_.Enqueue(first);
foreach (var value in rest) {
this.Enqueue(value);
Expand Down
15 changes: 10 additions & 5 deletions FinModelUtility/Fin/Fin/src/data/queues/FinTuple3Queue.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;

namespace fin.data.queues;
Expand All @@ -8,7 +9,7 @@ public interface ITuple3Queue<T1, T2, T3> : IEnumerable<(T1, T2, T3)> {

void Clear();

void Enqueue((T1, T2, T3) first, params (T1, T2, T3)[] rest);
void Enqueue((T1, T2, T3) first, params ReadOnlySpan<(T1, T2, T3)> rest);
void Enqueue(IEnumerable<(T1, T2, T3)> values);

(T1, T2, T3) Dequeue();
Expand All @@ -23,7 +24,8 @@ public class FinTuple3Queue<T1, T2, T3> : ITuple3Queue<T1, T2, T3> {

public FinTuple3Queue() { }

public FinTuple3Queue((T1, T2, T3) first, params (T1, T2, T3)[] rest)
public FinTuple3Queue((T1, T2, T3) first,
params ReadOnlySpan<(T1, T2, T3)> rest)
=> this.Enqueue(first, rest);

public FinTuple3Queue(IEnumerable<(T1, T2, T3)> values)
Expand All @@ -33,7 +35,8 @@ public FinTuple3Queue(IEnumerable<(T1, T2, T3)> values)

public void Clear() => this.impl_.Clear();

public void Enqueue((T1, T2, T3) first, params (T1, T2, T3)[] rest) {
public void Enqueue((T1, T2, T3) first,
params ReadOnlySpan<(T1, T2, T3)> rest) {
this.impl_.Enqueue(first);
foreach (var value in rest) {
this.Enqueue(value);
Expand Down Expand Up @@ -75,5 +78,7 @@ public bool TryPeek(out T1 value1, out T2 value2, out T3 value3) {
}

IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
public IEnumerator<(T1, T2, T3)> GetEnumerator() => this.impl_.GetEnumerator();

public IEnumerator<(T1, T2, T3)> GetEnumerator()
=> this.impl_.GetEnumerator();
}
5 changes: 3 additions & 2 deletions FinModelUtility/Fin/Fin/src/data/queues/IFinQueue.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;

using schema.readOnly;

Expand All @@ -9,7 +10,7 @@ namespace fin.data.queues;
/// </summary>
[GenerateReadOnly]
public partial interface IFinQueue<T> : IFinCollection<T> {
void Enqueue(T first, params T[] rest);
void Enqueue(T first, params ReadOnlySpan<T> rest);
void Enqueue(IEnumerable<T> values);

T Dequeue();
Expand Down

0 comments on commit f4a2811

Please sign in to comment.