Show More
Commit Description:
Support multiple data series.
Commit Description:
Support multiple data series.
References:
File last commit:
Show/Diff file:
Action:
encompass-cs/encompass-cs/IDManager.cs
28 lines | 527 B | text/x-csharp | CSharpLexer
28 lines | 527 B | text/x-csharp | CSharpLexer
r169 | using System.Collections.Generic; | |||
namespace Encompass | ||||
{ | ||||
internal class IDManager | ||||
{ | ||||
int _nextID = 0; | ||||
private readonly Stack<int> _availableIDs = new Stack<int>(); | ||||
public int NextID() | ||||
{ | ||||
if (_availableIDs.Count > 0) | ||||
{ | ||||
return _availableIDs.Pop(); | ||||
} | ||||
else | ||||
{ | ||||
return _nextID++; | ||||
} | ||||
} | ||||
public void Free(int id) | ||||
{ | ||||
_availableIDs.Push(id); | ||||
} | ||||
} | ||||
} | ||||