diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2020-04-19 17:19:32 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2020-04-19 17:19:32 -0400 |
| commit | c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 (patch) | |
| tree | ee4d51c7c1d633e11f46453ef1edd3c77c4ef9f7 /Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/FastAction.cs | |
| download | Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.gz Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.tar.bz2 Project-Sandbox-c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78.zip | |
Inital commit
Diffstat (limited to 'Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/FastAction.cs')
| -rw-r--r-- | Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/FastAction.cs | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/FastAction.cs b/Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/FastAction.cs new file mode 100644 index 0000000..15012e3 --- /dev/null +++ b/Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/FastAction.cs @@ -0,0 +1,146 @@ +using UnityEngine;
+using System.Collections;
+using System.Collections.Generic;
+
+
+namespace TMPro
+{
+ public class FastAction
+ {
+
+ LinkedList<System.Action> delegates = new LinkedList<System.Action>();
+
+ Dictionary<System.Action, LinkedListNode<System.Action>> lookup = new Dictionary<System.Action, LinkedListNode<System.Action>>();
+
+ public void Add(System.Action rhs)
+ {
+ if (lookup.ContainsKey(rhs)) return;
+
+ lookup[rhs] = delegates.AddLast(rhs);
+ }
+
+ public void Remove(System.Action rhs)
+ {
+ if (lookup.TryGetValue(rhs, out LinkedListNode<System.Action> node))
+ {
+ lookup.Remove(rhs);
+ delegates.Remove(node);
+ }
+ }
+
+ public void Call()
+ {
+ var node = delegates.First;
+ while (node != null)
+ {
+ node.Value();
+ node = node.Next;
+ }
+ }
+ }
+
+
+ public class FastAction<A>
+ {
+
+ LinkedList<System.Action<A>> delegates = new LinkedList<System.Action<A>>();
+
+ Dictionary<System.Action<A>, LinkedListNode<System.Action<A>>> lookup = new Dictionary<System.Action<A>, LinkedListNode<System.Action<A>>>();
+
+ public void Add(System.Action<A> rhs)
+ {
+ if (lookup.ContainsKey(rhs)) return;
+
+ lookup[rhs] = delegates.AddLast(rhs);
+ }
+
+ public void Remove(System.Action<A> rhs)
+ {
+ if (lookup.TryGetValue(rhs, out LinkedListNode<System.Action<A>> node))
+ {
+ lookup.Remove(rhs);
+ delegates.Remove(node);
+ }
+ }
+
+ public void Call(A a)
+ {
+ var node = delegates.First;
+ while (node != null)
+ {
+ node.Value(a);
+ node = node.Next;
+ }
+ }
+ }
+
+
+ public class FastAction<A, B>
+ {
+
+ LinkedList<System.Action<A, B>> delegates = new LinkedList<System.Action<A, B>>();
+
+ Dictionary<System.Action<A, B>, LinkedListNode<System.Action<A, B>>> lookup = new Dictionary<System.Action<A, B>, LinkedListNode<System.Action<A, B>>>();
+
+ public void Add(System.Action<A, B> rhs)
+ {
+ if (lookup.ContainsKey(rhs)) return;
+
+ lookup[rhs] = delegates.AddLast(rhs);
+ }
+
+ public void Remove(System.Action<A, B> rhs)
+ {
+ if (lookup.TryGetValue(rhs, out LinkedListNode<System.Action<A, B>> node))
+ {
+ lookup.Remove(rhs);
+ delegates.Remove(node);
+ }
+ }
+
+ public void Call(A a, B b)
+ {
+ var node = delegates.First;
+ while (node != null)
+ {
+ node.Value(a, b);
+ node = node.Next;
+ }
+ }
+ }
+
+
+ public class FastAction<A, B, C>
+ {
+
+ LinkedList<System.Action<A, B, C>> delegates = new LinkedList<System.Action<A, B, C>>();
+
+ Dictionary<System.Action<A, B, C>, LinkedListNode<System.Action<A, B, C>>> lookup = new Dictionary<System.Action<A, B, C>, LinkedListNode<System.Action<A, B, C>>>();
+
+ public void Add(System.Action<A, B, C> rhs)
+ {
+ if (lookup.ContainsKey(rhs)) return;
+
+ lookup[rhs] = delegates.AddLast(rhs);
+ }
+
+ public void Remove(System.Action<A, B, C> rhs)
+ {
+ if (lookup.TryGetValue(rhs, out LinkedListNode<System.Action<A, B, C>> node))
+ {
+ lookup.Remove(rhs);
+ delegates.Remove(node);
+ }
+ }
+
+ public void Call(A a, B b, C c)
+ {
+ var node = delegates.First;
+ while (node != null)
+ {
+ node.Value(a, b, c);
+ node = node.Next;
+ }
+ }
+ }
+}
\ No newline at end of file |
