/// <summary> /// Remove a point from its class. /// </summary> /// <param name="p">Point to remove.</param> /// <returns>True if the point was removed, false if it was not previously a member of any class.</returns> public bool Remove(TPoint p) { TLabel label; if (!PointToLabel.TryGetValue(p, out label)) { return(false); } PointToLabel.Remove(p); var oldPoints = LabelToPoints[label]; var didRemove = oldPoints.Remove(p); if (oldPoints.Count == 0) { LabelToPoints.Remove(label); } return(didRemove); }
/// <summary> /// Get the class label for a point. /// </summary> /// <param name="p">Point whose label is sought.</param> /// <returns>The label. If the point is not present, return default(TLabel), which is likely null.</returns> public TLabel GetClassLabel(TPoint p) { TLabel label; return(!PointToLabel.TryGetValue(p, out label) ? default(TLabel) : label); }