docs: Adding missing comments to IcdHashSet

This commit is contained in:
Chris Cameron
2018-05-25 16:40:37 -04:00
parent 3cddc14880
commit a178ebe8cb

View File

@@ -67,6 +67,11 @@ namespace ICD.Common.Utils.Collections
#region Methods #region Methods
/// <summary>
/// Returns a set containing all of this sets items plus all of the items in the given set.
/// </summary>
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI] [PublicAPI]
public IcdHashSet<T> Union(IEnumerable<T> set) public IcdHashSet<T> Union(IEnumerable<T> set)
{ {
@@ -80,6 +85,11 @@ namespace ICD.Common.Utils.Collections
return unionSet; return unionSet;
} }
/// <summary>
/// Returns a new set of this sets items exluding the items in the given set.
/// </summary>
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI] [PublicAPI]
public IcdHashSet<T> Subtract(IEnumerable<T> set) public IcdHashSet<T> Subtract(IEnumerable<T> set)
{ {
@@ -94,13 +104,11 @@ namespace ICD.Common.Utils.Collections
return subtractSet; return subtractSet;
} }
[PublicAPI] /// <summary>
public bool IsSubsetOf(IcdHashSet<T> set) /// Returns all of the items that are common between this set and the given set.
{ /// </summary>
IcdHashSet<T> setToCompare = set ?? NullSet; /// <param name="set"></param>
return this.All(setToCompare.Contains); /// <returns></returns>
}
[PublicAPI] [PublicAPI]
public IcdHashSet<T> Intersection(IcdHashSet<T> set) public IcdHashSet<T> Intersection(IcdHashSet<T> set)
{ {
@@ -126,40 +134,74 @@ namespace ICD.Common.Utils.Collections
[PublicAPI] [PublicAPI]
public IcdHashSet<T> NonIntersection(IcdHashSet<T> set) public IcdHashSet<T> NonIntersection(IcdHashSet<T> set)
{ {
return Subtract(set).Union(set.Subtract(this)); IcdHashSet<T> setToCompare = set ?? NullSet;
return Subtract(set).Union(setToCompare.Subtract(this));
} }
/// <summary>
/// Returns true if the given set contains all of the items in this set.
/// </summary>
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI]
public bool IsSubsetOf(IcdHashSet<T> set)
{
IcdHashSet<T> setToCompare = set ?? NullSet;
return this.All(setToCompare.Contains);
}
/// <summary>
/// Returns true if the given set contains all of the items in this set, and the sets are not equal.
/// </summary>
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI] [PublicAPI]
public bool IsProperSubsetOf(IcdHashSet<T> set) public bool IsProperSubsetOf(IcdHashSet<T> set)
{ {
IcdHashSet<T> setToCompare = set ?? NullSet; IcdHashSet<T> setToCompare = set ?? NullSet;
// Is a proper subset if A is a subset of B and A != B return IsSubsetOf(setToCompare) && !setToCompare.IsSubsetOf(this);
return (IsSubsetOf(setToCompare) && !setToCompare.IsSubsetOf(this));
} }
/// <summary>
/// Returns true if this set contains all of the items in the given set.
/// </summary>
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI] [PublicAPI]
public bool IsSupersetOf(IcdHashSet<T> set) public bool IsSupersetOf(IcdHashSet<T> set)
{ {
IcdHashSet<T> setToCompare = set ?? NullSet; IcdHashSet<T> setToCompare = set ?? NullSet;
return setToCompare.IsSubsetOf(this); return setToCompare.IsSubsetOf(this);
} }
/// <summary>
/// Returns true if this set contains all of the items in the given set, and the sets are not equal.
/// </summary>
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI] [PublicAPI]
public bool IsProperSupersetOf(IcdHashSet<T> set) public bool IsProperSupersetOf(IcdHashSet<T> set)
{ {
IcdHashSet<T> setToCompare = set ?? NullSet; IcdHashSet<T> setToCompare = set ?? NullSet;
// B is a proper superset of A if B is a superset of A and A != B return IsSupersetOf(setToCompare) && !setToCompare.IsSupersetOf(this);
return (IsSupersetOf(setToCompare) && !setToCompare.IsSupersetOf(this));
} }
/// <summary>
/// Returns true if this set contains all of the items in the given set, and vice versa.
/// </summary>
/// <param name="set"></param>
/// <returns></returns>
[PublicAPI] [PublicAPI]
public bool SetEquals(IcdHashSet<T> set) public bool SetEquals(IcdHashSet<T> set)
{ {
var setToCompare = set ?? NullSet; IcdHashSet<T> setToCompare = set ?? NullSet;
return (IsSubsetOf(setToCompare) && setToCompare.IsSubsetOf(this)); return IsSupersetOf(setToCompare) && setToCompare.IsSupersetOf(this);
} }
#endregion #endregion