forked from jasder/antlr
Use IEnumerable
This commit is contained in:
parent
9a351761d6
commit
9e9be6427d
|
@ -33,11 +33,13 @@ using System.Text;
|
|||
using Antlr4.Runtime.Atn;
|
||||
using Antlr4.Runtime.Misc;
|
||||
using Sharpen;
|
||||
using IEnumerable = System.Collections.IEnumerable;
|
||||
using IEnumerator = System.Collections.IEnumerator;
|
||||
|
||||
namespace Antlr4.Runtime.Atn
|
||||
{
|
||||
/// <author>Sam Harwell</author>
|
||||
public class ATNConfigSet : ISet<ATNConfig>
|
||||
public class ATNConfigSet : IEnumerable<ATNConfig>
|
||||
{
|
||||
/// <summary>
|
||||
/// This maps (state, alt) -> merged
|
||||
|
@ -301,7 +303,12 @@ namespace Antlr4.Runtime.Atn
|
|||
|
||||
public virtual IEnumerator<ATNConfig> GetEnumerator()
|
||||
{
|
||||
return new ATNConfigSet.ATNConfigSetIterator(this);
|
||||
return configs.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public virtual object[] ToArray()
|
||||
|
@ -446,13 +453,12 @@ namespace Antlr4.Runtime.Atn
|
|||
return true;
|
||||
}
|
||||
|
||||
public virtual bool AddAll<_T0>(ICollection<_T0> c) where _T0:ATNConfig
|
||||
public virtual bool AddAll(IEnumerable<ATNConfig> c)
|
||||
{
|
||||
return AddAll(c, null);
|
||||
}
|
||||
|
||||
public virtual bool AddAll<_T0>(ICollection<_T0> c, PredictionContextCache contextCache
|
||||
) where _T0:ATNConfig
|
||||
public virtual bool AddAll(IEnumerable<ATNConfig> c, PredictionContextCache contextCache)
|
||||
{
|
||||
EnsureWritable();
|
||||
bool changed = false;
|
||||
|
|
|
@ -114,5 +114,15 @@ namespace Antlr4.Runtime.Dfa
|
|||
public abstract int Size();
|
||||
|
||||
public abstract IDictionary<int, T> ToMap();
|
||||
|
||||
public virtual IEnumerator<KeyValuePair<int, T>> GetEnumerator()
|
||||
{
|
||||
return ToMap().GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,8 +85,8 @@ namespace Antlr4.Runtime.Dfa
|
|||
states.Sort(new _IComparer_85());
|
||||
foreach (DFAState s in states)
|
||||
{
|
||||
IDictionary<int, DFAState> edges = s.EdgeMap;
|
||||
IDictionary<int, DFAState> contextEdges = s.ContextEdgeMap;
|
||||
IEnumerable<KeyValuePair<int, DFAState>> edges = s.EdgeMap;
|
||||
IEnumerable<KeyValuePair<int, DFAState>> contextEdges = s.ContextEdgeMap;
|
||||
foreach (KeyValuePair<int, DFAState> entry in edges)
|
||||
{
|
||||
if ((entry.Value == null || entry.Value == ATNSimulator.Error) && !s.IsContextSymbol
|
||||
|
|
|
@ -35,7 +35,7 @@ using Sharpen;
|
|||
namespace Antlr4.Runtime.Dfa
|
||||
{
|
||||
/// <author>Sam Harwell</author>
|
||||
public interface IEdgeMap<T>
|
||||
public interface IEdgeMap<T> : IEnumerable<KeyValuePair<int, T>>
|
||||
{
|
||||
int Size();
|
||||
|
||||
|
|
Loading…
Reference in New Issue