DFA 字符串验证
我有一个程序,只需将所有状态作为一组状态作为输入。 然后采用的下一个输入是状态集中的初始状态,然后是最终状态集。
接下来是我在各州之间采取的一组过渡。
例如:q0,1,q1
这意味着在输入 1 上存在从 q0 到 q1 的转换。
对于每个状态,都会输入转换。
但在这里我面临的是引用可以以随机的方式跳跃 也就是说,对于非重复字符,转换可以是 n 个转换,因此我想动态地为每个状态维护一个 hashmap 对象。
我怎样才能实现这个目标?
I have a program that simply takes all the states as a set of states as a input.
And then the next input that is taken is the initial state among the set of states and then set of final states.
The next is a set of transition that I take among the states.
For example: q0,1,q1
This means on input one there is a transition from q0 to q1.
For each state the transitions are entered.
But here what I am facing is the refrences can be jumpled up in a random fashion
that is the transitions can be n number of transition for non duplicate characters, and hence cause of this I want to maintain a hashmap object for each state dynamically.
How can I achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于这是一个 DFA,因此维护从(状态、输入)对到结果状态的单个哈希图可能会更容易、更有效。 DFA 属性保证了可以以这种方式将转移关系视为函数。
因此,维护一个 HashMaptrans 并针对您给出的示例执行
trans.put(StateInput(q0, 1), q1)
,其中Since this is a DFA, it may be easier and more efficient to maintain a single hashmap from (state, input) pairs to resulting states. The DFA properties guarantee that the transition relation can be viewed as a function in this manner.
So, maintain a
HashMap<StateInput, State> trans
and dotrans.put(StateInput(q0, 1), q1)
for the example you gave, where也许是这样的?
Something like this, maybe?