-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathExtensions.cs
27 lines (24 loc) · 863 Bytes
/
Extensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//NCShark - By AlSch092 @ Github, thanks to @Diamondo25 for MapleShark
using System;
using System.Collections.Generic;
namespace NCShark
{
public static class Extensions
{
public static byte RollLeft(this byte pThis, int pCount)
{
uint overflow = ((uint)pThis) << (pCount % 8);
return (byte)((overflow & 0xFF) | (overflow >> 8));
}
public static byte RollRight(this byte pThis, int pCount)
{
uint overflow = (((uint)pThis) << 8) >> (pCount % 8);
return (byte)((overflow & 0xFF) | (overflow >> 8));
}
public static TValue GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> pThis, TKey pKey, TValue pDefault)
{
TValue result;
return pThis.TryGetValue(pKey, out result) ? result : pDefault;
}
}
}