//special thanks to chevy ray for this class <3
namespace Otter {
///
/// Class of utility functions for ref related things.
///
public static class Ref {
#region Static Methods
///
/// Swap two values.
///
/// The type of the values.
/// First value.
/// Second value.
public static void Swap(ref T a, ref T b) {
var temp = a;
a = b;
b = temp;
}
///
/// Shift three values.
///
/// The type of the values.
/// First value.
/// Second value.
/// Third value.
public static void Shift(ref T a, ref T b, ref T c) {
var temp = a;
a = b;
b = c;
c = temp;
}
///
/// Shift four values.
///
/// The type of the values.
/// First value.
/// Second value.
/// Third value.
/// Fourth value.
public static void Shift(ref T a, ref T b, ref T c, ref T d) {
var temp = a;
a = b;
b = c;
c = d;
d = temp;
}
///
/// Shift five values.
///
/// The type of the values.
/// First value.
/// Second value.
/// Third value.
/// Fourth value.
/// Fifth value.
public static void Shift(ref T a, ref T b, ref T c, ref T d, ref T e) {
var temp = a;
a = b;
b = c;
c = d;
d = e;
e = temp;
}
///
/// Shift six values.
///
/// The type of the values.
/// First value.
/// Second value.
/// Third value.
/// Fourth value.
/// Fifth value.
/// Sixth value.
public static void Shift(ref T a, ref T b, ref T c, ref T d, ref T e, ref T f) {
var temp = a;
a = b;
b = c;
c = d;
d = e;
e = f;
f = temp;
}
///
/// Test if a value equals any value on a list.
///
/// The type of the values.
/// The value to check for.
/// The values to check.
/// True if any of the values equal the value to check for.
public static bool EqualsAny(ref T p, params T[] values) {
foreach (var val in values)
if (val.Equals(p))
return true;
return false;
}
///
/// Test if a value equals any value on a list.
///
/// The type of the values.
/// The value to check for.
/// The values to check.
/// True if any of the values equal the value to check for.
public static bool EqualsAll(ref T p, params T[] values) {
foreach (var val in values)
if (!val.Equals(p))
return false;
return true;
}
#endregion
}
}