projects
/
mono.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
New test.
[mono.git]
/
mcs
/
class
/
corlib
/
System.Collections
/
BitArray.cs
diff --git
a/mcs/class/corlib/System.Collections/BitArray.cs
b/mcs/class/corlib/System.Collections/BitArray.cs
index 4d4109cd13be36a23120192adb9cd5fc958f1e2a..1ecb765c93227c1504740b34f0254dc0e7d89d7a 100644
(file)
--- a/
mcs/class/corlib/System.Collections/BitArray.cs
+++ b/
mcs/class/corlib/System.Collections/BitArray.cs
@@
-31,12
+31,16
@@
//
using System;
//
using System;
+using System.Runtime.InteropServices;
namespace System.Collections {
namespace System.Collections {
+#if NET_2_0
+ [ComVisible(true)]
+#endif
[Serializable]
public sealed class BitArray : ICollection, ICloneable {
[Serializable]
public sealed class BitArray : ICollection, ICloneable {
- int [] _array;
- int _length;
+ int []
m
_array;
+ int
m
_length;
int _version = 0;
#region Constructors
int _version = 0;
#region Constructors
@@
-45,10
+49,10
@@
namespace System.Collections {
if (bits == null)
throw new ArgumentNullException ("bits");
if (bits == null)
throw new ArgumentNullException ("bits");
-
_length = bits.
_length;
-
_array = new int [(
_length + 31) / 32];
+
m_length = bits.m
_length;
+
m_array = new int [(m
_length + 31) / 32];
- Array.Copy(bits.
_array, _array,
_array.Length);
+ Array.Copy(bits.
m_array, m_array, m
_array.Length);
}
public BitArray (bool [] values)
}
public BitArray (bool [] values)
@@
-56,8
+60,8
@@
namespace System.Collections {
if (values == null)
throw new ArgumentNullException ("values");
if (values == null)
throw new ArgumentNullException ("values");
- _length = values.Length;
-
_array = new int [(
_length + 31) / 32];
+
m
_length = values.Length;
+
m_array = new int [(m
_length + 31) / 32];
for (int i = 0; i < values.Length; i++)
this [i] = values [i];
for (int i = 0; i < values.Length; i++)
this [i] = values [i];
@@
-68,8
+72,8
@@
namespace System.Collections {
if (bytes == null)
throw new ArgumentNullException ("bytes");
if (bytes == null)
throw new ArgumentNullException ("bytes");
- _length = bytes.Length * 8;
-
_array = new int [(
_length + 31) / 32];
+
m
_length = bytes.Length * 8;
+
m_array = new int [(m
_length + 31) / 32];
for (int i = 0; i < bytes.Length; i++)
setByte (i, bytes [i]);
for (int i = 0; i < bytes.Length; i++)
setByte (i, bytes [i]);
@@
-81,9
+85,9
@@
namespace System.Collections {
throw new ArgumentNullException ("values");
int arrlen = values.Length;
throw new ArgumentNullException ("values");
int arrlen = values.Length;
- _length = arrlen*32;
- _array = new int [arrlen];
- Array.Copy (values, _array, arrlen);
+
m
_length = arrlen*32;
+
m
_array = new int [arrlen];
+ Array.Copy (values,
m
_array, arrlen);
}
public BitArray (int length)
}
public BitArray (int length)
@@
-91,22
+95,22
@@
namespace System.Collections {
if (length < 0)
throw new ArgumentOutOfRangeException ("length");
if (length < 0)
throw new ArgumentOutOfRangeException ("length");
- _length = length;
-
_array = new int [(
_length + 31) / 32];
+
m
_length = length;
+
m_array = new int [(m
_length + 31) / 32];
}
public BitArray (int length, bool defaultValue) : this (length)
{
if (defaultValue) {
}
public BitArray (int length, bool defaultValue) : this (length)
{
if (defaultValue) {
- for (int i = 0; i < _array.Length; i++)
- _array[i] = ~0;
+ for (int i = 0; i <
m
_array.Length; i++)
+
m
_array[i] = ~0;
}
}
private BitArray (int [] array, int length)
{
}
}
private BitArray (int [] array, int length)
{
- _array = array;
- _length = length;
+
m
_array = array;
+
m
_length = length;
}
#endregion
#region Utility Methods
}
#endregion
#region Utility Methods
@@
-116,7
+120,7
@@
namespace System.Collections {
int index = byteIndex / 4;
int shift = (byteIndex % 4) * 8;
int index = byteIndex / 4;
int shift = (byteIndex % 4) * 8;
- int theByte = _array [index] & (0xff << shift);
+ int theByte =
m
_array [index] & (0xff << shift);
return (byte)((theByte >> shift) & 0xff);
}
return (byte)((theByte >> shift) & 0xff);
}
@@
-127,9
+131,9
@@
namespace System.Collections {
int shift = (byteIndex % 4) * 8;
// clear the byte
int shift = (byteIndex % 4) * 8;
// clear the byte
- _array [index] &= ~(0xff << shift);
+
m
_array [index] &= ~(0xff << shift);
// or in the new byte
// or in the new byte
- _array [index] |= value << shift;
+
m
_array [index] |= value << shift;
_version++;
}
_version++;
}
@@
-138,13
+142,13
@@
namespace System.Collections {
{
if (operand == null)
throw new ArgumentNullException ();
{
if (operand == null)
throw new ArgumentNullException ();
- if (operand.
_length !=
_length)
+ if (operand.
m_length != m
_length)
throw new ArgumentException ();
}
#endregion
public int Count {
throw new ArgumentException ();
}
#endregion
public int Count {
- get { return _length; }
+ get { return
m
_length; }
}
public bool IsReadOnly {
}
public bool IsReadOnly {
@@
-161,21
+165,21
@@
namespace System.Collections {
}
public int Length {
}
public int Length {
- get { return _length; }
+ get { return
m
_length; }
set {
if (value < 0)
throw new ArgumentOutOfRangeException ();
int newLen = value;
set {
if (value < 0)
throw new ArgumentOutOfRangeException ();
int newLen = value;
- if (_length != newLen) {
+ if (
m
_length != newLen) {
int numints = (newLen + 31) / 32;
int [] newArr = new int [numints];
int numints = (newLen + 31) / 32;
int [] newArr = new int [numints];
- int copylen = (numints >
_array.Length) ?
_array.Length : numints;
- Array.Copy (_array, newArr, copylen);
+ int copylen = (numints >
m_array.Length) ? m
_array.Length : numints;
+ Array.Copy (
m
_array, newArr, copylen);
// set the internal state
// set the internal state
- _array = newArr;
- _length = newLen;
+
m
_array = newArr;
+
m
_length = newLen;
_version++;
}
}
_version++;
}
}
@@
-207,17
+211,17
@@
namespace System.Collections {
// in each case, check to make sure enough space in array
if (array is bool []) {
// in each case, check to make sure enough space in array
if (array is bool []) {
- if (array.Length - index < _length)
+ if (array.Length - index <
m
_length)
throw new ArgumentException ();
bool [] barray = (bool []) array;
// Copy the bits into the array
throw new ArgumentException ();
bool [] barray = (bool []) array;
// Copy the bits into the array
- for (int i = 0; i < _length; i++)
+ for (int i = 0; i <
m
_length; i++)
barray[index + i] = this [i];
} else if (array is byte []) {
barray[index + i] = this [i];
} else if (array is byte []) {
- int numbytes = (_length + 7) / 8;
+ int numbytes = (
m
_length + 7) / 8;
if ((array.Length - index) < numbytes)
throw new ArgumentException ();
if ((array.Length - index) < numbytes)
throw new ArgumentException ();
@@
-229,7
+233,7
@@
namespace System.Collections {
} else if (array is int []) {
} else if (array is int []) {
- Array.Copy (
_array, 0, array, index, (
_length + 31) / 32);
+ Array.Copy (
m_array, 0, array, index, (m
_length + 31) / 32);
} else {
throw new ArgumentException ("array", "Unsupported type");
} else {
throw new ArgumentException ("array", "Unsupported type");
@@
-238,9
+242,9
@@
namespace System.Collections {
public BitArray Not ()
{
public BitArray Not ()
{
- int ints = (_length + 31) / 32;
+ int ints = (
m
_length + 31) / 32;
for (int i = 0; i < ints; i++)
for (int i = 0; i < ints; i++)
-
_array [i] = ~
_array [i];
+
m_array [i] = ~m
_array [i];
_version++;
return this;
_version++;
return this;
@@
-250,9
+254,9
@@
namespace System.Collections {
{
checkOperand (value);
{
checkOperand (value);
- int ints = (_length + 31) / 32;
+ int ints = (
m
_length + 31) / 32;
for (int i = 0; i < ints; i++)
for (int i = 0; i < ints; i++)
-
_array [i] &= value.
_array [i];
+
m_array [i] &= value.m
_array [i];
_version++;
return this;
_version++;
return this;
@@
-262,9
+266,9
@@
namespace System.Collections {
{
checkOperand (value);
{
checkOperand (value);
- int ints = (_length + 31) / 32;
+ int ints = (
m
_length + 31) / 32;
for (int i = 0; i < ints; i++)
for (int i = 0; i < ints; i++)
-
_array [i] |= value.
_array [i];
+
m_array [i] |= value.m
_array [i];
_version++;
return this;
_version++;
return this;
@@
-274,9
+278,9
@@
namespace System.Collections {
{
checkOperand (value);
{
checkOperand (value);
- int ints = (_length + 31) / 32;
+ int ints = (
m
_length + 31) / 32;
for (int i = 0; i < ints; i++)
for (int i = 0; i < ints; i++)
-
_array [i] ^= value.
_array [i];
+
m_array [i] ^= value.m
_array [i];
_version++;
return this;
_version++;
return this;
@@
-284,21
+288,21
@@
namespace System.Collections {
public bool Get (int index)
{
public bool Get (int index)
{
- if (index < 0 || index >= _length)
+ if (index < 0 || index >=
m
_length)
throw new ArgumentOutOfRangeException ();
throw new ArgumentOutOfRangeException ();
- return (
_array [index / 32] & (1 << (index % 32
))) != 0;
+ return (
m_array [index >> 5] & (1 << (index & 31
))) != 0;
}
public void Set (int index, bool value)
{
}
public void Set (int index, bool value)
{
- if (index < 0 || index >= _length)
+ if (index < 0 || index >=
m
_length)
throw new ArgumentOutOfRangeException ();
if (value)
throw new ArgumentOutOfRangeException ();
if (value)
-
_array [index / 32] |= (1 << (index % 32
));
+
m_array [index >> 5] |= (1 << (index & 31
));
else
else
-
_array [index / 32] &= ~(1 << (index % 32
));
+
m_array [index >> 5] &= ~(1 << (index & 31
));
_version++;
}
_version++;
}
@@
-306,11
+310,11
@@
namespace System.Collections {
public void SetAll (bool value)
{
if (value) {
public void SetAll (bool value)
{
if (value) {
- for (int i = 0; i < _array.Length; i++)
- _array[i] = ~0;
+ for (int i = 0; i <
m
_array.Length; i++)
+
m
_array[i] = ~0;
}
else
}
else
- Array.Clear (
_array, 0,
_array.Length);
+ Array.Clear (
m_array, 0, m
_array.Length);
_version++;
}
_version++;
}
@@
-334,7
+338,7
@@
namespace System.Collections {
{
_index = -1;
_bitArray = ba;
{
_index = -1;
_bitArray = ba;
- _max = ba._length;
+ _max = ba.
m
_length;
_version = ba._version;
}
_version = ba._version;
}
@@
-376,4
+380,4
@@
namespace System.Collections {
}
}
}
}
}
}
-}
\ No newline at end of file
+}