forked from umbraco/Umbraco-CMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,017 additions
and
910 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,39 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Umbraco.Core.Collections | ||
namespace Umbraco.Cms.Core.Collections | ||
{ | ||
/// <summary> | ||
/// Collection that can be both a queue and a stack. | ||
/// Collection that can be both a queue and a stack. | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public class StackQueue<T> | ||
{ | ||
private readonly LinkedList<T> _linkedList = new LinkedList<T>(); | ||
private readonly LinkedList<T> _linkedList = new(); | ||
|
||
public void Clear() | ||
{ | ||
_linkedList.Clear(); | ||
} | ||
public int Count => _linkedList.Count; | ||
|
||
public void Push(T obj) | ||
{ | ||
_linkedList.AddFirst(obj); | ||
} | ||
public void Clear() => _linkedList.Clear(); | ||
|
||
public void Enqueue(T obj) | ||
{ | ||
_linkedList.AddFirst(obj); | ||
} | ||
public void Push(T obj) => _linkedList.AddFirst(obj); | ||
|
||
public void Enqueue(T obj) => _linkedList.AddFirst(obj); | ||
|
||
public T Pop() | ||
{ | ||
var obj = _linkedList.First.Value; | ||
T obj = _linkedList.First.Value; | ||
_linkedList.RemoveFirst(); | ||
return obj; | ||
} | ||
|
||
public T Dequeue() | ||
{ | ||
var obj = _linkedList.Last.Value; | ||
T obj = _linkedList.Last.Value; | ||
_linkedList.RemoveLast(); | ||
return obj; | ||
} | ||
|
||
public T PeekStack() | ||
{ | ||
return _linkedList.First.Value; | ||
} | ||
public T PeekStack() => _linkedList.First.Value; | ||
|
||
public T PeekQueue() | ||
{ | ||
return _linkedList.Last.Value; | ||
} | ||
|
||
public int Count | ||
{ | ||
get | ||
{ | ||
return _linkedList.Count; | ||
} | ||
} | ||
public T PeekQueue() => _linkedList.Last.Value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.