diff options
author | Adam Frisby | 2008-04-29 14:04:55 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-29 14:04:55 +0000 |
commit | 375163a6fece8b3a57c7555246abe8338223a599 (patch) | |
tree | 163001ca96a4b4d08589e9772f78510677d5d0dc /OpenSim/Framework/UndoStack.cs | |
parent | Patch from Melanie: 0001087: Crash to bash de-linking objects. Thanks Melanie! (diff) | |
download | opensim-SC-375163a6fece8b3a57c7555246abe8338223a599.zip opensim-SC-375163a6fece8b3a57c7555246abe8338223a599.tar.gz opensim-SC-375163a6fece8b3a57c7555246abe8338223a599.tar.bz2 opensim-SC-375163a6fece8b3a57c7555246abe8338223a599.tar.xz |
* Spring cleaning.
* Added new generic "Location" class to handle 2D integer locations. Going to use it to replace all RegionHandle and X,Y coordinate references throughout the entire project. You have been warned.
Diffstat (limited to 'OpenSim/Framework/UndoStack.cs')
-rw-r--r-- | OpenSim/Framework/UndoStack.cs | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/OpenSim/Framework/UndoStack.cs b/OpenSim/Framework/UndoStack.cs index 0b97644..a49a0cc 100644 --- a/OpenSim/Framework/UndoStack.cs +++ b/OpenSim/Framework/UndoStack.cs | |||
@@ -26,8 +26,6 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | 29 | ||
32 | namespace OpenSim.Framework | 30 | namespace OpenSim.Framework |
33 | { | 31 | { |
@@ -38,35 +36,39 @@ namespace OpenSim.Framework | |||
38 | [Serializable] | 36 | [Serializable] |
39 | public class UndoStack<T> | 37 | public class UndoStack<T> |
40 | { | 38 | { |
41 | |||
42 | private int m_new = 1; | 39 | private int m_new = 1; |
43 | private int m_old = 0; | 40 | private int m_old = 0; |
44 | private T[] m_Undos; | 41 | private T[] m_Undos; |
45 | 42 | ||
43 | public UndoStack(int capacity) | ||
44 | { | ||
45 | m_Undos = new T[capacity + 1]; | ||
46 | } | ||
47 | |||
46 | public bool IsFull | 48 | public bool IsFull |
47 | { | 49 | { |
48 | get | 50 | get { return m_new == m_old; } |
49 | { | ||
50 | return m_new == m_old; | ||
51 | } | ||
52 | } | 51 | } |
53 | 52 | ||
54 | 53 | ||
55 | public int Capacity | 54 | public int Capacity |
56 | { | 55 | { |
56 | get { return m_Undos.Length - 1; } | ||
57 | } | ||
58 | |||
59 | public int Count | ||
60 | { | ||
57 | get | 61 | get |
58 | { | 62 | { |
59 | return m_Undos.Length - 1; | 63 | int count = m_new - m_old - 1; |
64 | if (count < 0) | ||
65 | count += m_Undos.Length; | ||
66 | return count; | ||
60 | } | 67 | } |
61 | } | 68 | } |
62 | 69 | ||
63 | |||
64 | public UndoStack(int capacity) | ||
65 | { | ||
66 | m_Undos = new T[capacity + 1]; | ||
67 | } | ||
68 | 70 | ||
69 | public void Push(T item) | 71 | public void Push(T item) |
70 | { | 72 | { |
71 | if (IsFull) | 73 | if (IsFull) |
72 | { | 74 | { |
@@ -93,24 +95,13 @@ namespace OpenSim.Framework | |||
93 | throw new InvalidOperationException("Cannot pop from emtpy stack"); | 95 | throw new InvalidOperationException("Cannot pop from emtpy stack"); |
94 | } | 96 | } |
95 | 97 | ||
96 | public int Count | ||
97 | { | ||
98 | get | ||
99 | { | ||
100 | int count = m_new - m_old - 1; | ||
101 | if (count < 0) | ||
102 | count += m_Undos.Length; | ||
103 | return count; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | 98 | ||
108 | public T Peek() | 99 | public T Peek() |
109 | { | 100 | { |
110 | return m_Undos[m_new]; | 101 | return m_Undos[m_new]; |
111 | } | 102 | } |
112 | 103 | ||
113 | 104 | ||
114 | public void Clear() | 105 | public void Clear() |
115 | { | 106 | { |
116 | if (Count > 0) | 107 | if (Count > 0) |
@@ -123,6 +114,5 @@ namespace OpenSim.Framework | |||
123 | m_old = 0; | 114 | m_old = 0; |
124 | } | 115 | } |
125 | } | 116 | } |
126 | |||
127 | } | 117 | } |
128 | } \ No newline at end of file | 118 | } \ No newline at end of file |