2009-06-25 07:16:22 -07:00
|
|
|
|
/*
|
|
|
|
|
* VsqBPList.cs
|
|
|
|
|
* Copyright (c) 2008-2009 kbinani
|
|
|
|
|
*
|
|
|
|
|
* This file is part of Boare.Lib.Vsq.
|
|
|
|
|
*
|
|
|
|
|
* Boare.Lib.Vsq is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the BSD License.
|
|
|
|
|
*
|
|
|
|
|
* Boare.Lib.Vsq is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
*/
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
using bocoree;
|
|
|
|
|
|
2009-06-25 07:16:22 -07:00
|
|
|
|
namespace Boare.Lib.Vsq {
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
using boolean = System.Boolean;
|
|
|
|
|
|
2009-06-25 07:16:22 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// BPListのデータ部分を取り扱うためのクラス。
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class VsqBPList : ICloneable {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
private SortedList<int, VsqBPPair> m_list = new SortedList<int, VsqBPPair>();
|
2009-09-07 03:44:18 -07:00
|
|
|
|
private int m_default = 0;
|
|
|
|
|
private int m_maximum = 127;
|
|
|
|
|
private int m_minimum = 0;
|
2009-07-30 08:02:59 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// このリストに設定されたidの最大値.次にデータ点が追加されたときは,個の値+1がidとして利用される.削除された場合でも減らない
|
|
|
|
|
/// </summary>
|
|
|
|
|
private int m_max_id = 0;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
|
|
|
|
|
private class KeyClockIterator : Iterator {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
private SortedList<int, VsqBPPair> m_list;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
private int m_pos;
|
|
|
|
|
|
2009-07-30 08:02:59 -07:00
|
|
|
|
public KeyClockIterator( SortedList<int, VsqBPPair> list ) {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
m_list = list;
|
|
|
|
|
m_pos = -1;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public boolean hasNext() {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
if ( m_pos + 1 < m_list.Keys.Count ) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object next() {
|
|
|
|
|
m_pos++;
|
|
|
|
|
return m_list.Keys[m_pos];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void remove() {
|
|
|
|
|
if ( 0 <= m_pos && m_pos < m_list.Keys.Count ) {
|
|
|
|
|
int key = m_list.Keys[m_pos];
|
|
|
|
|
m_list.Remove( key );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-29 10:03:20 -07:00
|
|
|
|
public VsqBPList()
|
|
|
|
|
: this( 0, 0, 64 ) {
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public int Default {
|
|
|
|
|
get {
|
|
|
|
|
return getDefault();
|
|
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
setDefault( value );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// このBPListのデフォルト値を取得します
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int getDefault() {
|
|
|
|
|
return m_default;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDefault( int value ) {
|
|
|
|
|
m_default = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// データ点のIDを一度クリアし,新たに番号付けを行います.
|
|
|
|
|
/// IDは,Redo,Undo用コマンドが使用するため,このメソッドを呼ぶとRedo,Undo操作が破綻する.XMLからのデシリアライズ直後のみ使用するべき.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void renumberIDs() {
|
|
|
|
|
m_max_id = 0;
|
|
|
|
|
for ( Iterator itr = keyClockIterator(); itr.hasNext(); ) {
|
|
|
|
|
VsqBPPair item = (VsqBPPair)itr.next();
|
|
|
|
|
m_max_id++;
|
|
|
|
|
item.id = m_max_id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-29 10:03:20 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// XMLシリアライズ用
|
|
|
|
|
/// </summary>
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public String Data {
|
2009-07-29 10:03:20 -07:00
|
|
|
|
get {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
String ret = "";
|
2009-07-29 10:03:20 -07:00
|
|
|
|
int count = -1;
|
|
|
|
|
foreach ( int key in m_list.Keys ) {
|
|
|
|
|
count++;
|
2009-07-30 08:02:59 -07:00
|
|
|
|
ret += (count == 0 ? "" : "," ) + key + "=" + m_list[key].value;
|
2009-07-29 10:03:20 -07:00
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
m_list.Clear();
|
2009-07-30 08:02:59 -07:00
|
|
|
|
m_max_id = 0;
|
2009-09-07 03:44:18 -07:00
|
|
|
|
String[] spl = value.Split( ',' );
|
2009-07-29 10:03:20 -07:00
|
|
|
|
for ( int i = 0; i < spl.Length; i++ ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
String[] spl2 = spl[i].Split( '=' );
|
2009-07-29 10:03:20 -07:00
|
|
|
|
if ( spl2.Length < 2 ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
try {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
m_list.Add( int.Parse( spl2[0] ), new VsqBPPair( int.Parse( spl2[1] ), m_max_id + 1 ) );
|
|
|
|
|
m_max_id++;
|
2009-07-29 10:03:20 -07:00
|
|
|
|
} catch ( Exception ex ) {
|
|
|
|
|
#if DEBUG
|
|
|
|
|
Console.WriteLine( " ex=" + ex );
|
|
|
|
|
Console.WriteLine( " i=" + i + "; spl2[0]=" + spl2[0] + "; spl2[1]=" + spl2[1] );
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-25 07:16:22 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// このVsqBPListの同一コピーを作成します
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public Object clone() {
|
|
|
|
|
VsqBPList res = new VsqBPList( getDefault(), getMinimum(), getMaximum() );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
foreach ( int key in m_list.Keys ) {
|
|
|
|
|
res.m_list.Add( key, m_list[key] );
|
|
|
|
|
}
|
2009-09-07 03:44:18 -07:00
|
|
|
|
res.m_max_id = m_max_id;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public object Clone() {
|
|
|
|
|
return clone();
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-25 07:16:22 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// コンストラクタ。デフォルト値はココで指定する。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="default_value"></param>
|
|
|
|
|
public VsqBPList( int default_value, int minimum, int maximum ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
m_default = default_value;
|
|
|
|
|
m_maximum = maximum;
|
|
|
|
|
m_minimum = minimum;
|
2009-07-30 08:02:59 -07:00
|
|
|
|
m_max_id = 0;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public int Maximum {
|
|
|
|
|
get {
|
|
|
|
|
return getMaximum();
|
|
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
setMaximum( value );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-25 07:16:22 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// このリストに設定された最大値を取得します。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int getMaximum() {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
return m_maximum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMaximum( int value ){
|
|
|
|
|
m_maximum = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Minimum {
|
|
|
|
|
get {
|
|
|
|
|
return getMinimum();
|
|
|
|
|
}
|
|
|
|
|
set {
|
|
|
|
|
setMinimum( value );
|
|
|
|
|
}
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// このリストに設定された最小値を取得します
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int getMinimum() {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
return m_minimum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMinimum( int value ) {
|
|
|
|
|
m_minimum = value;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Iterator keyClockIterator() {
|
|
|
|
|
return new KeyClockIterator( m_list );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void remove( int clock ) {
|
|
|
|
|
if ( m_list.ContainsKey( clock ) ) {
|
|
|
|
|
m_list.Remove( clock );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public boolean isContainsKey( int clock ) {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
return m_list.ContainsKey( clock );
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public int size() {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
return m_list.Count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int[] getKeys() {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
Vector<int> t = new Vector<int>();
|
2009-07-29 10:03:20 -07:00
|
|
|
|
foreach( int key in m_list.Keys ){
|
2009-09-07 03:44:18 -07:00
|
|
|
|
t.add( key );
|
|
|
|
|
}
|
|
|
|
|
return t.toArray( new Int32[]{} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 時刻clockのデータを時刻new_clockに移動します。
|
|
|
|
|
/// 時刻clockにデータがなければ何もしない。
|
|
|
|
|
/// 時刻new_clockに既にデータがある場合、既存のデータは削除される。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="clock"></param>
|
|
|
|
|
/// <param name="new_clock"></param>
|
|
|
|
|
public void move( int clock, int new_clock, int new_value ) {
|
|
|
|
|
if ( !m_list.ContainsKey( clock ) ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
VsqBPPair item = m_list[clock];
|
|
|
|
|
m_list.Remove( clock );
|
|
|
|
|
if ( m_list.ContainsKey( new_clock ) ) {
|
|
|
|
|
m_list.Remove( new_clock );
|
2009-07-29 10:03:20 -07:00
|
|
|
|
}
|
2009-09-07 03:44:18 -07:00
|
|
|
|
item.value = new_value;
|
|
|
|
|
m_list.Add( new_clock, item );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void clear() {
|
|
|
|
|
m_list.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 新しいデータ点を追加します。
|
2009-09-07 03:44:18 -07:00
|
|
|
|
/// 戻り値に、新しいデータ点のIDを返します
|
2009-06-25 07:16:22 -07:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="clock"></param>
|
|
|
|
|
/// <param name="value"></param>
|
2009-09-07 03:44:18 -07:00
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public long add( int clock, int value ) {
|
2009-06-25 07:16:22 -07:00
|
|
|
|
lock ( m_list ) {
|
|
|
|
|
if ( m_list.ContainsKey( clock ) ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
VsqBPPair v = m_list[clock];
|
|
|
|
|
v.value = value;
|
|
|
|
|
m_list[clock] = v;
|
2009-09-07 03:44:18 -07:00
|
|
|
|
return v.id;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
} else {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
VsqBPPair v = new VsqBPPair( value, m_max_id + 1 );
|
|
|
|
|
m_max_id++;
|
2009-09-07 03:44:18 -07:00
|
|
|
|
#if DEBUG
|
|
|
|
|
//Console.WriteLine( "VsqBPList#add; m_max_id=" + m_max_id );
|
|
|
|
|
#endif
|
2009-07-30 08:02:59 -07:00
|
|
|
|
m_list.Add( clock, v );
|
2009-09-07 03:44:18 -07:00
|
|
|
|
return m_max_id;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-29 10:03:20 -07:00
|
|
|
|
public int getElement( int index ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
return getElementA( index );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getElementA( int index ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
return m_list[m_list.Keys[index]].value;
|
2009-07-29 10:03:20 -07:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public VsqBPPair getElementB( int index ) {
|
|
|
|
|
return m_list[m_list.Keys[index]];
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-29 10:03:20 -07:00
|
|
|
|
public int getKeyClock( int index ) {
|
|
|
|
|
return m_list.Keys[index];
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public int findValueFromID( long id ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
int c = m_list.Keys.Count;
|
|
|
|
|
foreach ( int key in m_list.Keys ) {
|
|
|
|
|
if ( m_list[key].id == id ) {
|
|
|
|
|
return m_list[key].value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-09-07 03:44:18 -07:00
|
|
|
|
return m_default;
|
2009-07-30 08:02:59 -07:00
|
|
|
|
}
|
|
|
|
|
|
2009-09-07 03:44:18 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 指定したid値を持つVsqBPPairを検索し、その結果を返します。
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public VsqBPPairSearchContext findElement( long id ) {
|
|
|
|
|
VsqBPPairSearchContext context = new VsqBPPairSearchContext();
|
|
|
|
|
int c = m_list.Keys.Count;
|
|
|
|
|
for ( int i = 0; i < c; i++ ) {
|
|
|
|
|
int clock = m_list.Keys[i];
|
|
|
|
|
VsqBPPair item = m_list[clock];
|
|
|
|
|
if ( item.id == id ) {
|
|
|
|
|
context.clock = clock;
|
|
|
|
|
context.index = i;
|
|
|
|
|
context.point = item;
|
|
|
|
|
return context;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
context.clock = -1;
|
|
|
|
|
context.index = -1;
|
|
|
|
|
context.point = new VsqBPPair( m_default, -1 );
|
|
|
|
|
return context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setValueForID( long id, int value ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
int c = m_list.Keys.Count;
|
|
|
|
|
foreach ( int key in m_list.Keys ) {
|
|
|
|
|
if ( m_list[key].id == id ) {
|
|
|
|
|
VsqBPPair v = m_list[key];
|
|
|
|
|
v.value = value;
|
|
|
|
|
m_list[key] = v;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-29 10:03:20 -07:00
|
|
|
|
public int getValue( int clock, ref int index ) {
|
|
|
|
|
if ( m_list.Count == 0 ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
return m_default;
|
2009-07-29 10:03:20 -07:00
|
|
|
|
} else {
|
|
|
|
|
if ( index < 0 ) {
|
|
|
|
|
index = 0;
|
|
|
|
|
}
|
|
|
|
|
for ( int i = index ; i < m_list.Keys.Count; i++ ) {
|
|
|
|
|
int keyclock = m_list.Keys[i];
|
|
|
|
|
if ( clock < keyclock ) {
|
|
|
|
|
if ( i > 0 ) {
|
|
|
|
|
index = i;
|
2009-07-30 08:02:59 -07:00
|
|
|
|
return m_list[m_list.Keys[i - 1]].value;
|
2009-07-29 10:03:20 -07:00
|
|
|
|
} else {
|
|
|
|
|
index = i;
|
2009-09-07 03:44:18 -07:00
|
|
|
|
return m_default;
|
2009-07-29 10:03:20 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
index = m_list.Keys.Count - 1;
|
2009-07-30 08:02:59 -07:00
|
|
|
|
return m_list[m_list.Keys[m_list.Keys.Count - 1]].value;
|
2009-07-29 10:03:20 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getValue( int clock ) {
|
|
|
|
|
if ( m_list.Count == 0 ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
return m_default;
|
2009-07-29 10:03:20 -07:00
|
|
|
|
} else {
|
|
|
|
|
for ( int i = 0; i < m_list.Keys.Count; i++ ) {
|
|
|
|
|
int keyclock = m_list.Keys[i];
|
|
|
|
|
if ( clock < keyclock ) {
|
|
|
|
|
if ( i > 0 ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
return m_list[m_list.Keys[i - 1]].value;
|
2009-07-29 10:03:20 -07:00
|
|
|
|
} else {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
return m_default;
|
2009-07-29 10:03:20 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-07-30 08:02:59 -07:00
|
|
|
|
return m_list[m_list.Keys[m_list.Keys.Count - 1]].value;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// このBPListの内容をテキストファイルに書き出します
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="writer"></param>
|
|
|
|
|
public void print( StreamWriter writer ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
boolean first = true;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
foreach ( int key in m_list.Keys ) {
|
2009-07-30 08:02:59 -07:00
|
|
|
|
int val = m_list[key].value;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
if ( first ) {
|
|
|
|
|
writer.WriteLine( key + "=" + val );
|
|
|
|
|
first = false;
|
|
|
|
|
} else {
|
|
|
|
|
writer.WriteLine( key + "=" + val );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// このBPListの内容をテキストファイルに書き出します
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="writer"></param>
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public void print( TextMemoryStream writer, int start, String header ) {
|
|
|
|
|
boolean first = true;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
foreach ( int key in m_list.Keys ) {
|
|
|
|
|
if ( start <= key ) {
|
|
|
|
|
if ( first ) {
|
|
|
|
|
writer.writeLine( header );
|
|
|
|
|
first = false;
|
|
|
|
|
}
|
2009-07-30 08:02:59 -07:00
|
|
|
|
int val = m_list[key].value;
|
2009-06-25 07:16:22 -07:00
|
|
|
|
writer.writeLine( key + "=" + val );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// テキストファイルからデータ点を読込み、現在のリストに追加します
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="reader"></param>
|
|
|
|
|
/// <returns></returns>
|
2009-09-07 03:44:18 -07:00
|
|
|
|
public String appendFromText( TextMemoryStream reader ) {
|
|
|
|
|
String last_line = reader.readLine();
|
2009-06-25 07:16:22 -07:00
|
|
|
|
while ( !last_line.StartsWith( "[" ) ) {
|
2009-09-07 03:44:18 -07:00
|
|
|
|
String[] spl = last_line.Split( new char[] { '=' } );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
int i1 = int.Parse( spl[0] );
|
|
|
|
|
int i2 = int.Parse( spl[1] );
|
2009-07-30 08:02:59 -07:00
|
|
|
|
VsqBPPair v = new VsqBPPair( i2, m_max_id + 1 );
|
|
|
|
|
m_max_id++;
|
|
|
|
|
m_list.Add( i1, v );
|
2009-06-25 07:16:22 -07:00
|
|
|
|
if ( reader.peek() < 0 ) {
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
last_line = reader.readLine();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return last_line;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|