Skip to content

Commit 9645878

Browse files
authored
Merge pull request #108 from wlsnmrk/doc/update-readme-code-style
doc: update README code style to editorconfig
2 parents a04bc57 + aef426e commit 9645878

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

README.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ A simple `LinkedHashSet` implementation is provided that provides basic set sema
2626
`LinkedHashSet` provides struct enumerators for efficient, allocation-free enumeration.
2727

2828
```csharp
29-
var set = new LinkedHashSet<string>() {
29+
var set = new LinkedHashSet<string>()
30+
{
3031
"c",
3132
"b",
3233
"a",
@@ -48,7 +49,8 @@ A simple `LinkedHashMap` implementation is provided that provides full dictionar
4849
> While preserving insertion order can be useful in certain situations, the tradeoff is that a `LinkedList` and a `Dictionary` are both used under the hood as the backing store. While this is lightweight and leverages .NET's efficient collection implementations, the linked list still allocates on the heap for every insertion and violates cache locality. For all but the most intense use cases, this will generally be acceptable where maintaining insertion order is desired. Otherwise, just use .NET's Dictionary<TKey, TValue>.
4950
5051
```csharp
51-
var map = new LinkedHashMap<string, int>() {
52+
var map = new LinkedHashMap<string, int>()
53+
{
5254
["b"] = 2,
5355
["a"] = 1,
5456
};
@@ -91,7 +93,8 @@ var table = new EntityTable<int>();
9193
table.Set(42, "dolphins");
9294

9395
// Use pattern matching for an optimal experience.
94-
if (table.Get<string>(42) is { } value) {
96+
if (table.Get<string>(42) is { } value)
97+
{
9598
Console.WriteLine("Dolphins are present.");
9699
}
97100

@@ -105,7 +108,8 @@ var table = new EntityTable();
105108

106109
table.Set("identifier", new object())
107110

108-
if (table.Get<object>("identifier") is { } value) {
111+
if (table.Get<object>("identifier") is { } value)
112+
{
109113
Console.WriteLine("Object is present.");
110114
}
111115
```
@@ -117,8 +121,10 @@ The boxless queue allows you to queue struct values on the heap without boxing t
117121
To do so, you must make an object which implements the `IBoxlessValueHandler` interface. The `HandleValue` method will be invoked whenever the boxless queue dequeues a value.
118122

119123
```csharp
120-
public class MyValueHandler : IBoxlessValueHandler {
121-
public void HandleValue<TValue>(in TValue value) where TValue : struct {
124+
public class MyValueHandler : IBoxlessValueHandler
125+
{
126+
public void HandleValue<TValue>(in TValue value) where TValue : struct
127+
{
122128
Console.WriteLine($"Received value {value}");
123129
}
124130
}
@@ -135,7 +141,8 @@ Once you have implemented the `IBoxlessValueHandler`, you can create a boxless q
135141
queue.Enqueue(valueA);
136142

137143
// See if anything is in the queue.
138-
if (queue.HasValues) {
144+
if (queue.HasValues)
145+
{
139146
Console.WriteLine("Something in the queue.");
140147
}
141148

@@ -150,7 +157,8 @@ A simple object pool implementation is provided that allows you to pre-allocate
150157
Any object you wish to store in a pool must conform to `IPooled` and implement the required `Reset` method. The reset method is called when the object is returned to the pool, allowing you to reset the object's state.
151158

152159
```csharp
153-
public abstract class Shape : IPooled {
160+
public abstract class Shape : IPooled
161+
{
154162
public void Reset() { }
155163
}
156164

@@ -188,7 +196,8 @@ A pool can be easily created. Each derived type that you wish to pool can be "re
188196
A typed facade over `OrderedDictionary`. Provides a basic mechanism to store strongly typed keys and values while preserving key insertion order.
189197

190198
```csharp
191-
var map = new Map<string, int>() {
199+
var map = new Map<string, int>()
200+
{
192201
["b"] = 2,
193202
["a"] = 1,
194203
};
@@ -208,21 +217,24 @@ AutoProps are basically a simplified version of a `BehaviorSubject` that only up
208217
```csharp
209218
using Chickensoft.Collections;
210219

211-
public class MyObject : IDisposable {
220+
public class MyObject : IDisposable
221+
{
212222
// Read-only version exposed as interface.
213223
public IAutoProp<bool> MyValue => _myValue;
214224

215225
// Read-write version.
216226
private readonly AutoProp<bool> _myValue = new AutoProp<bool>(false);
217227

218-
public void Update() {
228+
public void Update()
229+
{
219230
// Update our values based on new information.
220231
_myValue.OnNext(true);
221232

222233
// ...
223234
224235
// Check the latest value.
225-
if (_myValue.Value) {
236+
if (_myValue.Value)
237+
{
226238
// ...
227239
}
228240

0 commit comments

Comments
 (0)