From: handa Date: Fri, 16 Jan 2009 05:10:38 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cce76c7e303b96cc6d0bd02f946deaa61f2ae3a1;p=m17n%2Fm17n-lib-cs.git *** empty log message *** --- diff --git a/MText.cs b/MText.cs index 185ec08..836c4f4 100644 --- a/MText.cs +++ b/MText.cs @@ -42,7 +42,7 @@ namespace M17N.Core } } - public class MText : IEnumerable, IComparable, IEquatable + public class MText : IEnumerable, IEquatable, IComparable { #if false public enum MTextFormat format; @@ -110,23 +110,25 @@ namespace M17N.Core return mt; } + // Public properties public bool ReadOnly { get { return read_only; } } public int Length { get { return nchars; } } + // Public methods + + // for IEnumerable interface + public IEnumerator GetEnumerator() { return new MTextEnum (this); } + + // for IEquatable interface + public bool Equals (MText other) { return this.sb.Equals (other.sb); } + + // for IComparable interface public int CompareTo (MText other) { return this.sb.ToString ().CompareTo (other.sb.ToString ()); } - public bool Equals (MText other) - { - return this.sb.Equals (other.sb); - } - - public override String ToString () - { - return sb.ToString (); - } + public override String ToString () { return sb.ToString (); } private static bool surrogate_high_p (char c) { @@ -202,6 +204,16 @@ namespace M17N.Core int to_idx = pos_to_idx (mt2, to); sb.Insert (pos_idx, mt2.sb.ToString (from_idx, to_idx - from_idx)); +#if false + if (root_interval != null) + { + MInterval interval; + + if (mt2.root_interval != null) + interval = mt2.root_interval.Copy (from, to); + root_interval.Insert (pos, interval); + } +#endif nchars += to - from; } @@ -265,11 +277,6 @@ namespace M17N.Core root_interval.Push (from, to, prop); } - public IEnumerator GetEnumerator() - { - return new MTextEnum (this); - } - private class MInterval { // Start and end positions of this interval and its children. @@ -282,6 +289,11 @@ namespace M17N.Core private int depth; private MInterval left, right, parent; + private static int adjust_position (int pos, bool front_inclusive) + { + return (pos << 2) + (front_inclusive ? -1 : 1); + } + public MInterval (int start, bool front_inclusive, int end, bool rear_inclusive) { @@ -301,6 +313,16 @@ namespace M17N.Core this.depth = 1; } + public MInterval Copy (int start, int end, MInterval interval) + { + MInterval new_interval; + + start = adjust_position (start, true); + end = adjust_position (end, true); + new_interval = new MInterval (start, end, interval.stack); + return new_interval; + } + private MInterval Copy () { return new MInterval (total_start, total_end, stack); @@ -370,6 +392,10 @@ namespace M17N.Core push (start, end, prop); } + public void Insert (int start, int end, MInterval interval) + { + } + private MInterval divide_right (int pos) { MInterval interval = Copy ();