Help us understand the problem. What is going on with this article?

使いやすい入れ物

More than 1 year has passed since last update.

この入れ子構造が使いやすそう。たぶん

{
器1 : GlobalDictionary  (key , vector)
器2 : Vector (Dictionary)
器3 : Dictionary (key , value)  <-- このvalueに値を入れていく

器1の中に器2が入り、器2中には器3が入る
器1のkeyはsymbolをセットする

呼び出し方は
    GlobalDictionary.contain[key]でvectorを特定し、そのvectorの要素をforループで検索
    Dictionary.contain[key]で目的の値を取得sるう
}


using elsystem;         //datetime
using tsdata.common;    //TokenList
using tsdata.marketdata;//QuotesProvider
using elsystem.xml;     //xml
using elsystem.collections; //Vector,GlobalDictionary,Dictionary,Stack,Queue;

var:GlobalDictionary gdic(null);


method void AnalysisTechnique_inisialized( elsystem.Object sender, elsystem.InitializedEventArgs args ) 
var:string r;
begin
    gdic = GlobalDictionary.Create(false,"MyGlobalDictionary");

    setGdic("8798-TS" , "description" , "アドクリ");
    setGdic("8798-TS" , "last" , "1050" );
    r = getGdic("8798-TS" , "description");

    print(r);
    print(getGdic("8798-TS" , "last"));
    print(getGdic("8798-TS" , "alllast"));
    print(getGdic("7203-TS" , "description"));
    print(gdic.Count);
end;

method void setGdic(string strsymbol , string key , string value)
var:bool isContainsSymbol ,bool isContainsKey , Vector vec , Dictionary dic ,int n;
begin
    //初期値
    isContainsSymbol = gdic.Contains(strsymbol);    //GlobalDictionary : symbol既存データ有無フラグ
    isContainsKey = false;  //Dictionary : key既存データ有無フラグ


    if (isContainsSymbol = false ) then begin
        //GlobalDictionary : symbol既存データなし
        //すべて新規登録
        vec = Vector.Create();
        dic = Dictionary.Create();

        dic.Add(key,value);
        vec.push_back(dic);
        gdic.Add(strsymbol , vec);
    end;

    if(isContainsSymbol = true ) then begin
        //GlobalDictionary : symbol既存データあり
        //Dictionary : key既存データあり
        //この場合は既存Dictionary-key-valueを更新する。
        //そして、Dictionary : key既存データ有無フラグをtrueにセットする
        vec = gdic.Items[strsymbol] astype Vector;
        for n = 0 to vec.Count-1 begin
            dic = vec.Items[n] astype Dictionary;
            if dic.Contains(key) then begin
                //
                dic.Items[key] = value;
                isContainsKey = true;
            end;
        end;        
    end;

    if (isContainsSymbol = true and isContainsKey = false) then begin
        //symbol既存データなし
        //Dictionary : key既存データ有
        //Dictionaryのみ新規addしてVectorに追加
        vec = gdic.Items[strsymbol] astype Vector;
        dic = Dictionary.Create();
        dic.Add(key,value);
        vec.push_back(dic);
    end;
end;

method string getGdic(string strsymbol , string key)
var:string ret , int n , Vector vec , Dictionary dic;
begin
    //初期値
    ret = "";

    if (gdic.Contains(strsymbol)) then begin
        vec = gdic.Items[strsymbol] astype Vector;
        for n = 0 to vec.Count-1 begin
            dic = vec.Items[n] astype Dictionary;
            if(dic.Contains(key)) then ret = dic.Items[key].tostring();
        end;
    end
    else begin
        //なにもしない ret=""を返す    
    end;

    return ret;
end;

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした