From 7d7f5a1afc3118e400c2bd07ff408e1ba6d90aa5 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Sat, 23 Feb 2013 23:10:23 -0600 Subject: [PATCH] Add override BitSet.ToString --- runtime/CSharp/Antlr4.Runtime/Sharpen/BitSet.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/runtime/CSharp/Antlr4.Runtime/Sharpen/BitSet.cs b/runtime/CSharp/Antlr4.Runtime/Sharpen/BitSet.cs index 2b87a3c21..bee94324c 100644 --- a/runtime/CSharp/Antlr4.Runtime/Sharpen/BitSet.cs +++ b/runtime/CSharp/Antlr4.Runtime/Sharpen/BitSet.cs @@ -280,5 +280,22 @@ namespace Sharpen return result.GetHashCode(); } + + public override string ToString() + { + StringBuilder builder = new StringBuilder(); + builder.Append('{'); + + for (int i = NextSetBit(0); i >= 0; i = NextSetBit(i + 1)) + { + if (builder.Length > 1) + builder.Append(", "); + + builder.Append(i); + } + + builder.Append('}'); + return builder.ToString(); + } } }