Skip to content

Commit

Permalink
Rename methods, move dirs, remove commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
ddur committed Feb 14, 2016
1 parent a6d2906 commit 98f99ab
Show file tree
Hide file tree
Showing 17 changed files with 213 additions and 236 deletions.
2 changes: 1 addition & 1 deletion DBCL.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{0EAAAA
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NUnit.Text", "Source\Test\NUnit.Text\NUnit.Text.csproj", "{9D761E03-1000-447A-A81C-EC3ABAB21EDB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniCodeClassGenerator", "Source\Code\UniCodeClassGenerator\UniCodeClassGenerator\UniCodeClassGenerator.csproj", "{0AC896BC-CBBB-48B9-8704-F6992107B951}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniCodeClassGenerator", "Source\Code\UniCodeClassGenerator\UniCodeClassGenerator.csproj", "{0AC896BC-CBBB-48B9-8704-F6992107B951}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
6 changes: 3 additions & 3 deletions Source/Code/Collections/BitSetArray/BitSetArray.Theory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ private static class Theory {
public static bool IndexerGetItemValue (BitSetArray self, int item, bool getValue) {
Success success = true;
if (item.InRange (0, self.range - 1)) {
success.Assert (getValue == self.Get (item));
success.Assert (getValue == self._GetMember (item));
}
else {
success.Assert (getValue == false);
Expand Down Expand Up @@ -1158,7 +1158,7 @@ private static class Theory {
}

[Pure]
public static bool Get (BitSetArray self, int item, bool getValue) {
public static bool GetMember (BitSetArray self, int item, bool getValue) {
Success success = true;

if (item.InRange (0, self.range - 1)) {
Expand All @@ -1172,7 +1172,7 @@ private static class Theory {
}

[Pure]
public static bool Set (BitSetArray oldState, int item, bool setValue, BitSetArray newState, bool retValue) {
public static bool SetMember (BitSetArray oldState, int item, bool setValue, BitSetArray newState, bool retValue) {
Success success = true;

success.Assert (setValue == setValue.Bool ());
Expand Down
90 changes: 45 additions & 45 deletions Source/Code/Collections/BitSetArray/BitSetArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ public EnumeratorReverseReadOnly (BitSetArray that)
if (maxValue == int.MaxValue) { throw new IndexOutOfRangeException(); }

var retValue = new BitSetArray (maxValue + 1);
retValue.initItems (items, minValue, maxValue);
retValue._InitMembers (items, minValue, maxValue);
return retValue;
}

Expand Down Expand Up @@ -1820,13 +1820,13 @@ public EnumeratorReverseReadOnly (BitSetArray that)
[Pure]
get {
Contract.Ensures (Theory.IndexerGetItemValue (this, item, Contract.Result<bool> ()));
return this._Get (item);
return this._GetMember (item);
}
set { // returns void, only way to return error is exception
Contract.Requires<IndexOutOfRangeException> (
(value.Bool () == true && this.InRange (item)) || value.Bool () == false);
Contract.Ensures (Theory.IndexerSetItemValue (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, value, this));
this._Set (item, value.Bool());
this._SetMember (item, value.Bool());
}
}

Expand Down Expand Up @@ -2595,11 +2595,11 @@ public EnumeratorReverseReadOnly (BitSetArray that)
/// </summary>
/// <param name="items"></param>
/// <returns>Number of members added.</returns>
public int AddMembers (IEnumerable<int> items) {
public int Add (IEnumerable<int> items) {
Contract.Requires<ArgumentNullException> (items.IsNot (null));
Contract.Requires<ArgumentEmptyException> (!items.IsEmpty ());

// TODO? Contract.Ensures (Theory.ICollectionAdd (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), items, this));
// TODO? Contract.Ensures (Theory.Add (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), items, this));

if (items.IsNullOrEmpty()) { return 0; }
int start = int.MaxValue;
Expand All @@ -2617,35 +2617,33 @@ public EnumeratorReverseReadOnly (BitSetArray that)
if (final >= this.range) {
this.Length = final + 1;
}
return this._Set (items, true);
return this._SetMembers (items, true);
}

/// <summary>Removes IEnumerable&lt;int&gt; items where item is member
/// <para>No exceptions thrown.</para>
/// </summary>
/// <param name="items">int</param>
/// <returns>Number of items removed.</returns>
public int RemoveMembers (IEnumerable<int> items) {
public int Remove (IEnumerable<int> items) {
Contract.Requires<ArgumentNullException> (items.IsNot (null));
Contract.Requires<ArgumentEmptyException> (!items.IsEmpty ());

// TODO? Contract.Ensures (Theory.Remove (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, this, Contract.Result<bool> ()));

return this._Set(items, false);
return this._SetMembers(items, false);
}

// TODO: Implement Add/Remove for range of items

[Pure]
public bool Get (int item) {
Contract.Ensures (Theory.Get (this, item, Contract.Result<bool> ()));
public bool GetMember (int item) {
Contract.Ensures (Theory.GetMember (this, item, Contract.Result<bool> ()));

return _Get (item);
return _GetMember (item);
}

[Pure]
internal bool _Get (int item) {
Contract.Ensures (Theory.Get (this, item, Contract.Result<bool> ()));
internal bool _GetMember (int item) {
Contract.Ensures (Theory.GetMember (this, item, Contract.Result<bool> ()));

bool value = false;
lock (SyncRoot) {
Expand All @@ -2663,20 +2661,21 @@ public EnumeratorReverseReadOnly (BitSetArray that)
/// <param name="item"></param>
/// <param name="value"></param>
/// <returns>true if item set/cleared else returns false</returns>
public bool Set (int item, bool value = true) {
Contract.Ensures (Theory.Set (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, value, this, Contract.Result<bool>()));
public bool SetMember (int item, bool value = true) {
Contract.Ensures (Theory.SetMember (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, value, this, Contract.Result<bool>()));

return _Set (item, value);
return _SetMember (item, value);
}

/// <summary>
/// Set/Clear item if this.InRange(item) - internal
/// Set/Clear item if this.InRange(item)
/// </summary>
/// <remarks>Internal - No contracts on release build</remarks>
/// <param name="item"></param>
/// <param name="value"></param>
/// <returns>true if item set/cleared else returns false</returns>
internal bool _Set (int item, bool value = true) {
Contract.Ensures (Theory.Set (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, value, this, Contract.Result<bool>()));
internal bool _SetMember (int item, bool value = true) {
Contract.Ensures (Theory.SetMember (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, value, this, Contract.Result<bool>()));

value = value.Bool ();
bool isChanged = false;
Expand All @@ -2703,7 +2702,7 @@ public EnumeratorReverseReadOnly (BitSetArray that)
Contract.Assert (this.count > 0);
--this.count;
}
Contract.Assert (_Get(item) == value);
Contract.Assert (_GetMember(item) == value);
updateCache (oldVersion, oldCount, item, item, value);
}
}
Expand All @@ -2718,19 +2717,20 @@ public EnumeratorReverseReadOnly (BitSetArray that)
/// <param name="items">IEnumerable&lt;int&gt;</param>
/// <param name="value">bool, if true then set, else clear</param>
/// <returns>number of members set/cleared</returns>
public int Set (IEnumerable<int> items, bool value = true) {
// TODO: Contract.Ensures (Theory.SetInRange (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, value, this));
return _Set(items, value);
public int SetMembers (IEnumerable<int> items, bool value = true) {
// TODO? Contract.Ensures (Theory.SetMembers (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, value, this));
return _SetMembers(items, value);
}

/// <summary>
/// Set/Clear IEnumerable&lt;int&gt; items where this.InRange (item) - internal
/// Set/Clear IEnumerable&lt;int&gt; items where this.InRange (item)
/// </summary>
/// <remarks>Internal - No contracts on release build</remarks>
/// <param name="items">IEnumerable&lt;int&gt;</param>
/// <param name="value">bool, if true then set, else clear</param>
/// <returns>number of members set/cleared</returns>
internal int _Set (IEnumerable<int> items, bool value = true) {
// TODO: Contract.Ensures (Theory.TrySet (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, value, this));
internal int _SetMembers (IEnumerable<int> items, bool value = true) {
// TODO: Contract.Ensures (Theory.SetMembers (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, value, this));

lock (SyncRoot) {
if (items.IsNullOrEmpty()) { return 0; }
Expand Down Expand Up @@ -2771,29 +2771,29 @@ public EnumeratorReverseReadOnly (BitSetArray that)
}

/// <summary>
/// Set/Clear Range of items where this.InRange (item);
/// Set/Clear range of items where this.InRange (item)
/// </summary>
/// <remarks>Use Add to add any valid item and exception on invalid range items.</remarks>
/// <param name="start"></param>
/// <param name="final"></param>
/// <param name="value"></param>
/// <returns>number of members set/cleared</returns>
public int Set (int start, int final, bool value = true) {
// TODO: Contract.Ensures (Theory.Set (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, value, this));
/// <returns>Number of members set/cleared</returns>
public int SetMembersRange (int start, int final, bool value = true) {
// TODO? Contract.Ensures (Theory.SetMembersRange (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, value, this));

return _Set(start, final, value);
return _SetMembersRange(start, final, value);

}

/// <summary>
/// Set/Clear Range of items where this.InRange (item);
/// </summary>
/// <remarks>Internal - No contracts on release build</remarks>
/// <param name="rangeStart"></param>
/// <param name="rangeFinal"></param>
/// <param name="value"></param>
/// <returns>true if changed</returns>
internal int _Set (int rangeStart, int rangeFinal, bool value = true) {
// TODO: Contract.Ensures (Theory.Set (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, value, this));
/// <returns>Number of members set/cleared</returns>
internal int _SetMembersRange (int rangeStart, int rangeFinal, bool value = true) {
// TODO? Contract.Ensures (Theory.SetMembersRange (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, value, this));
// TODO: implement fast set/clear of array data when range index is larger than 2

lock (SyncRoot) {
Expand Down Expand Up @@ -2866,15 +2866,15 @@ public EnumeratorReverseReadOnly (BitSetArray that)
if (this.startVersion == oldVersion) {
// start cache has not expired
Contract.Assume (this.startMemoize != null);
if (_Get((int)this.startMemoize)) {
if (_GetMember((int)this.startMemoize)) {
// start item is not cleared, cache is alive
this.startVersion = this.version;
}
}
if (this.finalVersion == oldVersion) {
// final cache has not expired
Contract.Assume (this.finalMemoize != null);
if (_Get((int)this.finalMemoize)) {
if (_GetMember((int)this.finalMemoize)) {
// final item is not cleared, cache is alive
this.finalVersion = this.version;
}
Expand All @@ -2883,7 +2883,7 @@ public EnumeratorReverseReadOnly (BitSetArray that)
}
}

internal void initItems (IEnumerable<int> items, int minValue, int maxValue) {
internal void _InitMembers (IEnumerable<int> items, int minValue, int maxValue) {
Contract.Requires<InvalidOperationException> (this.Length != 0);
Contract.Requires<InvalidOperationException> (this.Count == 0);
Contract.Requires<ArgumentNullException> (items.IsNot (null));
Expand Down Expand Up @@ -3188,7 +3188,7 @@ public EnumeratorReverseReadOnly (BitSetArray that)
if (item >= this.range) {
this.Length = item + 1;
}
this._Set (item, true);
this._SetMember (item, true);
}

/// <summary>Implements ICollection{int}.Remove
Expand All @@ -3200,7 +3200,7 @@ public EnumeratorReverseReadOnly (BitSetArray that)
Contract.Ensures (Theory.Remove (Contract.OldValue<BitSetArray> (BitSetArray.Copy (this)), item, this, Contract.Result<bool> ()));

if (this[item]) {
return this._Set (item, false);
return this._SetMember (item, false);
}
return false; // not found
}
Expand Down Expand Up @@ -3295,7 +3295,7 @@ public EnumeratorReverseReadOnly (BitSetArray that)
this.Length = item + 1;
}
Contract.Assert (this.InRange (item));
return this._Set (item, true);
return this._SetMember (item, true);
}
}
return false;
Expand Down Expand Up @@ -3324,7 +3324,7 @@ public EnumeratorReverseReadOnly (BitSetArray that)
else {
// this will never ExceptWith(that) outside this.Length
// ExceptWith can simply ignore any value otside this.Length
this._Set (that, false); // -> this.AddVersion
this._SetMembers (that, false); // -> this.AddVersion
}
}

Expand Down Expand Up @@ -3353,7 +3353,7 @@ public EnumeratorReverseReadOnly (BitSetArray that)
}
else {
other = BitSetArray.Size (this.range);
other._Set (that);
other._SetMembers (that);
this.And (other);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Code/Collections/ICodeSet/CodeSetWide.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ public sealed class CodeSetWide : CodeSet {
private void populatePlaneBits (IEnumerable<int> bits, int offset) {
var bitPlanes = createPlaneBits ();
foreach (var item in bits) {
bitPlanes[(item >> 16) - this.startPlane]._Set (item & 0xFFFF);
bitPlanes[(item >> 16) - this.startPlane]._SetMember (item & 0xFFFF);
}
populatePlaneSets (bitPlanes, offset);
}

private void populatePlaneBits (IEnumerable<Code> codes) {
var bitPlanes = createPlaneBits ();
foreach (Code code in codes) {
bitPlanes[code.UnicodePlane () - this.startPlane]._Set (code & 0xFFFF);
bitPlanes[code.UnicodePlane () - this.startPlane]._SetMember (code & 0xFFFF);
}
populatePlaneSets (bitPlanes);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Code/Collections/ICodeSet/ICodeSetStaticFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static class Factory {
return CodeSetNone.Singleton;
}
var bits = BitSetArray.Size (Code.MaxCount);
bits.Set (func.ToIntCodes());
bits._SetMembers (func.ToIntCodes());
return bits.ToICodeSet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class CategoryBuilder : SourceBuilder
OpenStaticClass ("Category");

bool data = false;
// int countDown = 0;
int countData = 0;

var categoryName = string.Empty;
Expand Down Expand Up @@ -155,13 +154,6 @@ public class CategoryBuilder : SourceBuilder
Console.WriteLine ();

data = false;
// if (countData == 0) {
// WriteLine (24, "CodeSetNone.Singleton;");
// } else if (countData == 1) {
// WriteLine (";");
// } else {
// WriteLine (");");
// }
countData = 0;
WriteLine (16, "}");
WriteLine (16, "return (" + unionCatName + ");");
Expand All @@ -186,27 +178,14 @@ public class CategoryBuilder : SourceBuilder
if (Int32.TryParse (startValue, NumberStyles.HexNumber, null, out startInt)) {
if (!string.IsNullOrWhiteSpace (finalValue)
&& Int32.TryParse (finalValue, NumberStyles.HexNumber, null, out finalInt)) {
bits._Set (startInt, finalInt);
bits._SetMembersRange (startInt, finalInt);
} else {
bits._Set (startInt);
bits._SetMember (startInt);
}
} else {
throw new ArgumentException (line);
}
countData += 1;
// if (countDown == 2) {
// countDown -= 1;
// } else if (countDown == 1){
// countDown -= 1;
// WriteLine (".Union (");
// } else {
// WriteLine (",");
// }
// if (string.IsNullOrWhiteSpace (finalValue)) {
// Write (24, "((Code)0x" + startValue + ")");
// } else {
// Write (24, "((Code)0x" + startValue + ").Range (0x" + finalValue + ")");
// }
} else {
throw new ArgumentException ("No data match: " + line);
}
Expand All @@ -224,7 +203,6 @@ public class CategoryBuilder : SourceBuilder
categoryName = categoryMatch.Groups["name"].Value;
propertyName = categoryName.Replace ("_", "");
unionCatName = "_" + propertyName.Substring (0, 1).ToLower() + propertyName.Substring (1) + "_";
// countDown = 2;
WriteLine ();
WriteLine (08, "/// <summary>");
WriteLine (08, "/// Derived " + categoryName.Replace ('_', ' '));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DBCL.csproj">
<ProjectReference Include="..\DBCL.csproj">
<Project>{ca42ddc3-d6a2-4a7c-9f5c-e3e8dc0de55e}</Project>
<Name>DBCL</Name>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down

0 comments on commit 98f99ab

Please sign in to comment.