-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new python string builder class
- Loading branch information
1 parent
a3f54a1
commit 5ee0ec0
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Text; | ||
|
||
namespace Bonsai.ML.HiddenMarkovModels | ||
{ | ||
public abstract class PythonStringBuilder | ||
{ | ||
|
||
private string _cachedString; | ||
private bool _updateString; | ||
protected readonly StringBuilder StringBuilder = new StringBuilder(); | ||
|
||
protected void UpdateString() | ||
{ | ||
_updateString = true; | ||
} | ||
|
||
protected virtual string BuildString() | ||
{ | ||
return StringBuilder.ToString(); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
if (_updateString) | ||
{ | ||
_cachedString = BuildString(); | ||
_updateString = false; | ||
} | ||
return _cachedString; | ||
} | ||
} | ||
} | ||
|
||
|