Last change
on this file since 15812 was
15812,
checked in by lkammere, 6 years ago
|
#2886: Performance Improvements - Only store hash of archived phrases and reduce number of enumerators.
|
File size:
767 bytes
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Threading.Tasks;
|
---|
6 |
|
---|
7 | namespace HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration.GrammarEnumeration {
|
---|
8 | public class SymbolString : List<Symbol> {
|
---|
9 |
|
---|
10 | public SymbolString(int capacity) : base(capacity) { }
|
---|
11 |
|
---|
12 | public SymbolString(IEnumerable<Symbol> symbols) : base(symbols) { }
|
---|
13 |
|
---|
14 | public bool IsSentence() {
|
---|
15 | return this.All(sym => sym is TerminalSymbol);
|
---|
16 | }
|
---|
17 |
|
---|
18 | public int[] GetNonterminalSymbolIndexes() {
|
---|
19 | return Enumerable.Range(0, Count)
|
---|
20 | .Where(i => this[i] is NonterminalSymbol)
|
---|
21 | .ToArray();
|
---|
22 | }
|
---|
23 |
|
---|
24 | public override string ToString() {
|
---|
25 | return string.Join(" ", this);
|
---|
26 | }
|
---|
27 | }
|
---|
28 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.