ManagedGuidSet 2.0.0
dotnet add package ManagedGuidSet --version 2.0.0
NuGet\Install-Package ManagedGuidSet -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ManagedGuidSet" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ManagedGuidSet --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ManagedGuidSet, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ManagedGuidSet as a Cake Addin
#addin nuget:?package=ManagedGuidSet&version=2.0.0
// Install ManagedGuidSet as a Cake Tool
#tool nuget:?package=ManagedGuidSet&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ManagedGuidSet
A thread-safe HashSet<Guid> which stores upto a set capacity discarding older Guids as needed.
Useful for keeping track of old vs new things.
Features
- Loading saved Guids upon construction.
- Save current Guids for later loading.
- Set the capacity.
- See if a Guid is present in collection.
- Enumerable.
Time Complexities
- Add: O(1)
- Remove: O(1)
- Contains: O(1)
- Clear: O(1)
- Save: O(n)
- Load: O(n)
Usage
Properties
/// <summary>
/// The maximum amount of items until old items are discarded.
/// </summary>
public int Capacity
/// <summary>
/// How many items are currently in the collection.
/// </summary>
public int Size
Constructor
/// <summary>
/// Creates a new ManagedLookup collection.
/// </summary>
/// <param name="capacity">The initial capacity of the collection.</param>
/// <param name="path">The path to load saved Guids from.</param>
public ManagedGuidSet(int capacity = 3, string? path = null)
Methods
/// <summary>
/// Checks to see if a specific Guid is already in the collection.
/// </summary>
/// <param name="guid">The Guid to check.</param>
/// <returns>true if the specified Guid is present in the collection, false otherwise.</returns>
public bool Contains(Guid guid)
/// <summary>
/// Adds a Guid to the collection.
/// </summary>
/// <param name="guid">The Guid to be added.</param>
/// <returns>true if the Guid was added successfully, false otherwise.</returns>
public bool Add(Guid guid)
/// <summary>
/// Tries to remove the oldest item from the collection.
/// </summary>
/// <param name="guid">The removed Guid.</param>
/// <returns>true if an item was removed from the collection, false otherwise.</returns>
public bool TryRemove(out Guid? guid)
/// <summary>
/// Clears the collection.
/// </summary>
public void Clear()
/// <summary>
/// Saves the collection to disk.
/// </summary>
/// <param name="path">The full save path.</param>
/// <returns>true if save was successful, false otherwise.</returns>
public async Task<bool> Save(string? path = null)
Example
// Create a ManagedGuidSet with capacity of 600
ManagedGuidSet mgs = new(600);
// Adding a Guid
Guid newGuid = Guid.NewGuid();
mgs.Add(newGuid);
// Checking to see if the Guid is present
bool isPresent = mgs.Contains(newGuid);
// Removing the oldest Guid
if(mgs.TryRemove(out Guid? oldGuid))
{
Console.WriteLine($"Removed old Guid: {oldGuid}");
}
else
{
Console.WriteLine("Collection is Empty");
}
// Saving the collection to disk
string path = "some path here";
if(await msg.Save("Some Path here"))
Console.WriteLine("Saved.");
// Loading saved collection on construction with a new capacity of 300
ManagedGuidSet mgs2 = new(300, path);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.0 | 249 | 12/24/2021 |