-
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.
Updated the code examples to use remark-code-import
This copies the source code from the solutions to make sure it compiles and does not go out of date.
- Loading branch information
1 parent
1d8851e
commit 4918f3c
Showing
8 changed files
with
122 additions
and
86 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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
label: 'Specialized' | ||
position: 1 |
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
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
45 changes: 19 additions & 26 deletions
45
src/Extended.Collections.Playground/Generic/RingBufferSandbox.cs
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,34 +1,27 @@ | ||
using Extended.Collections.Generic; | ||
namespace Extended.Collections.Playground.Generic; | ||
using Extended.Collections.Generic; | ||
|
||
namespace Extended.Collections.Playground.Generic | ||
public class RingBufferSandbox : Sandbox | ||
{ | ||
public class RingBufferSandbox : Sandbox | ||
{ | ||
private readonly RingBuffer<string> m_buffer; | ||
|
||
public RingBufferSandbox() | ||
{ | ||
m_buffer = new RingBuffer<string>(3); | ||
} | ||
private readonly RingBuffer<string> m_buffer = new (3); | ||
|
||
protected override void Run() | ||
{ | ||
m_buffer.Add("A"); | ||
m_buffer.Add("B"); | ||
m_buffer.Add("C"); | ||
Logger.Information("1. {Buffer}", m_buffer); // 1. [ "A", "B", "C" ] | ||
protected override void Run() | ||
{ | ||
m_buffer.Add("A"); | ||
m_buffer.Add("B"); | ||
m_buffer.Add("C"); | ||
Logger.Information("1. {Buffer}", m_buffer); // 1. [ "A", "B", "C" ] | ||
|
||
m_buffer.Add("D"); | ||
Logger.Information("2. {Buffer}", m_buffer); // 2. [ "B", "C", "D" ] | ||
m_buffer.Add("D"); | ||
Logger.Information("2. {Buffer}", m_buffer); // 2. [ "B", "C", "D" ] | ||
|
||
m_buffer.Remove("C"); | ||
Logger.Information("3. {Buffer}", m_buffer); // 3. [ "B", "D" ] | ||
m_buffer.Remove("C"); | ||
Logger.Information("3. {Buffer}", m_buffer); // 3. [ "B", "D" ] | ||
|
||
m_buffer.Add("E"); | ||
Logger.Information("4. {Buffer}", m_buffer); // 4. [ "B", "D", "E" ] | ||
m_buffer.Add("E"); | ||
Logger.Information("4. {Buffer}", m_buffer); // 4. [ "B", "D", "E" ] | ||
|
||
m_buffer.Clear(); | ||
Logger.Information("5. {Buffer}", m_buffer); // [ ] | ||
} | ||
m_buffer.Clear(); | ||
Logger.Information("5. {Buffer}", m_buffer); // [ ] | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Extended.Collections.Playground/Generic/Specialized/OrderedDictionarySandbox.cs
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Extended.Collections.Generic.Specialized; | ||
using System.Collections; | ||
|
||
namespace Extended.Collections.Playground.Generic.Specialized; | ||
|
||
public class OrderedDictionarySandbox : Sandbox | ||
{ | ||
private OrderedDictionary<string, string> m_tasks = new (); | ||
|
||
protected override void Run() | ||
{ | ||
// Add tasks to the project in a specific order. | ||
m_tasks.Add("Task1", "Complete research"); | ||
m_tasks.Add("Task2", "Write documentation"); | ||
m_tasks.Add("Task3", "Test functionality"); | ||
|
||
// Access tasks by their keys while maintaining their order. | ||
Console.WriteLine("Project Tasks:"); | ||
foreach (KeyValuePair<string, string> entry in m_tasks) | ||
{ | ||
Console.WriteLine($"TaskId: {entry.Key}"); | ||
Console.WriteLine($"Name:{entry.Value}"); | ||
} | ||
|
||
// Remove | ||
m_tasks.RemoveAt(1); // Remove by index | ||
m_tasks.Remove("Task1"); // Remove by key | ||
|
||
Logger.Information("Value: {Value}", m_tasks); | ||
// 1. [ 'Task2' ] = "Write documentation" | ||
// 2. [ 'Task3' ] = "Test functionality" | ||
} | ||
} |