/// <summary>Return a set of keys such that the value of that key is not null.</summary> /// <returns> /// A hash set such that each element of the set is a key in this CoreMap that has a /// non-null value. /// </returns> public virtual ICollection <Type> KeySetNotNull() { ICollection <Type> mapKeys = new IdentityHashSet <Type>(); for (int i = 0; i < Size(); ++i) { if (values[i] != null) { mapKeys.Add(this.keys[i]); } } return(mapKeys); }
/// <summary>Prints a full dump of a CoreMap.</summary> /// <remarks> /// Prints a full dump of a CoreMap. This method is robust to /// circularity in the CoreMap. /// </remarks> /// <returns>A String representation of the CoreMap</returns> public override string ToString() { IdentityHashSet <ICoreMap> calledSet = toStringCalled.Get(); bool createdCalledSet = calledSet.IsEmpty(); if (calledSet.Contains(this)) { return("[...]"); } calledSet.Add(this); StringBuilder s = new StringBuilder("["); for (int i = 0; i < size; i++) { s.Append(keys[i].GetSimpleName()); s.Append('='); s.Append(values[i]); if (i < size - 1) { s.Append(' '); } } s.Append(']'); if (createdCalledSet) { toStringCalled.Remove(); } else { // Remove the object from the already called set so that // potential later calls in this object graph have something // more description than [...] calledSet.Remove(this); } return(s.ToString()); }