[Add] FishNet
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace MonoFN
|
||||
{
|
||||
internal static class Disposable
|
||||
{
|
||||
public static Disposable<T> Owned<T>(T value) where T : class, IDisposable
|
||||
{
|
||||
return new(value, owned: true);
|
||||
}
|
||||
|
||||
public static Disposable<T> NotOwned<T>(T value) where T : class, IDisposable
|
||||
{
|
||||
return new(value, owned: false);
|
||||
}
|
||||
}
|
||||
|
||||
internal struct Disposable<T> : IDisposable where T : class, IDisposable
|
||||
{
|
||||
internal readonly T value;
|
||||
private readonly bool owned;
|
||||
|
||||
public Disposable(T value, bool owned)
|
||||
{
|
||||
this.value = value;
|
||||
this.owned = owned;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (value != null && owned)
|
||||
value.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1aa8d86dc5c9323419e8b535d582fccf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 207815
|
||||
packageName: 'FishNet: Networking Evolved'
|
||||
packageVersion: 4.6.22R
|
||||
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono/Disposable.cs
|
||||
uploadId: 866910
|
||||
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using MonoFN.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace MonoFN
|
||||
{
|
||||
internal static class Empty<T>
|
||||
{
|
||||
public static readonly T[] Array = new T [0];
|
||||
}
|
||||
|
||||
internal class ArgumentNullOrEmptyException : ArgumentException
|
||||
{
|
||||
public ArgumentNullOrEmptyException(string paramName) : base("Argument null or empty", paramName) { }
|
||||
}
|
||||
}
|
||||
|
||||
namespace MonoFN.Cecil
|
||||
{
|
||||
internal static partial class Mixin
|
||||
{
|
||||
public static bool IsNullOrEmpty<T>(this T[] self)
|
||||
{
|
||||
return self == null || self.Length == 0;
|
||||
}
|
||||
|
||||
public static bool IsNullOrEmpty<T>(this Collection<T> self)
|
||||
{
|
||||
return self == null || self.size == 0;
|
||||
}
|
||||
|
||||
public static T[] Resize<T>(this T[] self, int length)
|
||||
{
|
||||
Array.Resize(ref self, length);
|
||||
return self;
|
||||
}
|
||||
|
||||
public static T[] Add<T>(this T[] self, T item)
|
||||
{
|
||||
if (self == null)
|
||||
{
|
||||
self = new[] { item };
|
||||
return self;
|
||||
}
|
||||
|
||||
self = self.Resize(self.Length + 1);
|
||||
self[self.Length - 1] = item;
|
||||
return self;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4662c38d1a951c24b89aeae3390acd39
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 207815
|
||||
packageName: 'FishNet: Networking Evolved'
|
||||
packageVersion: 4.6.22R
|
||||
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono/Empty.cs
|
||||
uploadId: 866910
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// Author:
|
||||
// Jb Evain (jbevain@gmail.com)
|
||||
//
|
||||
// Copyright (c) 2008 - 2015 Jb Evain
|
||||
// Copyright (c) 2008 - 2011 Novell, Inc.
|
||||
//
|
||||
// Licensed under the MIT/X11 license.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MonoFN
|
||||
{
|
||||
internal class MergeSort<T>
|
||||
{
|
||||
private readonly T[] elements;
|
||||
private readonly T[] buffer;
|
||||
private readonly IComparer<T> comparer;
|
||||
|
||||
private MergeSort(T[] elements, IComparer<T> comparer)
|
||||
{
|
||||
this.elements = elements;
|
||||
buffer = new T [elements.Length];
|
||||
Array.Copy(this.elements, buffer, elements.Length);
|
||||
this.comparer = comparer;
|
||||
}
|
||||
|
||||
public static void Sort(T[] source, IComparer<T> comparer)
|
||||
{
|
||||
Sort(source, 0, source.Length, comparer);
|
||||
}
|
||||
|
||||
public static void Sort(T[] source, int start, int length, IComparer<T> comparer)
|
||||
{
|
||||
new MergeSort<T>(source, comparer).Sort(start, length);
|
||||
}
|
||||
|
||||
private void Sort(int start, int length)
|
||||
{
|
||||
TopDownSplitMerge(buffer, elements, start, length);
|
||||
}
|
||||
|
||||
private void TopDownSplitMerge(T[] a, T[] b, int start, int end)
|
||||
{
|
||||
if (end - start < 2)
|
||||
return;
|
||||
|
||||
int middle = (end + start) / 2;
|
||||
TopDownSplitMerge(b, a, start, middle);
|
||||
TopDownSplitMerge(b, a, middle, end);
|
||||
TopDownMerge(a, b, start, middle, end);
|
||||
}
|
||||
|
||||
private void TopDownMerge(T[] a, T[] b, int start, int middle, int end)
|
||||
{
|
||||
for (int i = start, j = middle, k = start; k < end; k++)
|
||||
{
|
||||
if (i < middle && (j >= end || comparer.Compare(a[i], a[j]) <= 0))
|
||||
{
|
||||
b[k] = a[i++];
|
||||
}
|
||||
else
|
||||
{
|
||||
b[k] = a[j++];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c35ecf3bff670b4c8b367ed632eee37
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 207815
|
||||
packageName: 'FishNet: Networking Evolved'
|
||||
packageVersion: 4.6.22R
|
||||
assetPath: Assets/FishNet/CodeGenerating/cecil-0.11.4/Mono/MergeSort.cs
|
||||
uploadId: 866910
|
||||
Reference in New Issue
Block a user