From 6aa4042c006b0e7acf17eee1720fd360fec05609 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Mon, 18 Feb 2013 19:59:15 -0600 Subject: [PATCH] Updated collections --- Antlr4.Runtime/Atn/ATN.cs | 2 +- Antlr4.Runtime/Atn/ATNState.cs | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Antlr4.Runtime/Atn/ATN.cs b/Antlr4.Runtime/Atn/ATN.cs index 831c0b220..d99333795 100644 --- a/Antlr4.Runtime/Atn/ATN.cs +++ b/Antlr4.Runtime/Atn/ATN.cs @@ -65,7 +65,7 @@ namespace Antlr4.Runtime.Atn [NotNull] public readonly IDictionary modeNameToStartState = new - LinkedHashMap(); + Dictionary(); public int grammarType; diff --git a/Antlr4.Runtime/Atn/ATNState.cs b/Antlr4.Runtime/Atn/ATNState.cs index 2daf8c9f5..5fdf7ecb7 100644 --- a/Antlr4.Runtime/Atn/ATNState.cs +++ b/Antlr4.Runtime/Atn/ATNState.cs @@ -29,6 +29,7 @@ */ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using Antlr4.Runtime.Atn; using Antlr4.Runtime.Misc; using Sharpen; @@ -94,7 +95,7 @@ namespace Antlr4.Runtime.Atn { public const int InitialNumTransitions = 4; - public static readonly IList serializationNames = Sharpen.Collections.UnmodifiableList + public static readonly IReadOnlyList serializationNames = new ReadOnlyCollection (Arrays.AsList("INVALID", "BASIC", "RULE_START", "BLOCK_START", "PLUS_BLOCK_START" , "STAR_BLOCK_START", "TOKEN_START", "RULE_STOP", "BLOCK_END", "STAR_LOOP_BACK" , "STAR_LOOP_ENTRY", "PLUS_LOOP_BACK", "LOOP_END")); @@ -112,10 +113,10 @@ namespace Antlr4.Runtime.Atn /// Track the transitions emanating from this ATN state. /// Track the transitions emanating from this ATN state. - protected internal readonly IList transitions = new + protected internal readonly List transitions = new List(InitialNumTransitions); - protected internal IList optimizedTransitions; + protected internal List optimizedTransitions; /// Used to cache lookahead during parsing, not used during construction public IntervalSet nextTokenWithinRule; @@ -179,10 +180,9 @@ namespace Antlr4.Runtime.Atn return stateNumber.ToString(); } - public virtual Antlr4.Runtime.Atn.Transition[] GetTransitions() + public virtual Transition[] GetTransitions() { - return Sharpen.Collections.ToArray(transitions, new Antlr4.Runtime.Atn.Transition - [transitions.Count]); + return transitions.ToArray(); } public virtual int NumberOfTransitions @@ -203,12 +203,12 @@ namespace Antlr4.Runtime.Atn { if (epsilonOnlyTransitions != e.IsEpsilon) { - System.Console.Error.Format("ATN state %d has both epsilon and non-epsilon transitions.\n" + System.Console.Error.WriteLine("ATN state {0} has both epsilon and non-epsilon transitions." , stateNumber); epsilonOnlyTransitions = false; } } - transitions.AddItem(e); + transitions.Add(e); } public virtual Antlr4.Runtime.Atn.Transition Transition(int i) @@ -221,9 +221,9 @@ namespace Antlr4.Runtime.Atn transitions.Set(i, e); } - public virtual Antlr4.Runtime.Atn.Transition RemoveTransition(int index) + public virtual void RemoveTransition(int index) { - return transitions.RemoveAt(index); + transitions.RemoveAt(index); } public abstract Antlr4.Runtime.Atn.StateType StateType @@ -271,7 +271,7 @@ namespace Antlr4.Runtime.Atn { optimizedTransitions = new List(); } - optimizedTransitions.AddItem(e); + optimizedTransitions.Add(e); } public virtual void SetOptimizedTransition(int i, Antlr4.Runtime.Atn.Transition e