1

私はコードを書きます、それはGLib.Treeについてです。しかし、検索方法の使い方がわかりません。

Valadoc にはこれの例があり、動作します!

以下は私のコードです:

[indent = 4]

def cmp (a: string, b: string): int
    return strcmp (a, b)
init
    var t = new Tree of string, string (cmp)
    t.insert ("a", "aaa")
    t.insert ("b", "bbb")

    var needle = "A"
    fun: TreeSearchFunc = def (k)
        return strcmp (k.down(), needle.down())

    var ret = t.search (fun)

エラー!

エラー: 名前down' does not exist in the context ofK'

再試行:

    fun: TreeSearchFunc of string = def (k)

エラー!

エラー: 'GTreeSearchFunc' が宣言されていません

TreeSearchFunc 説明:

public delegate int TreeSearchFunc (K key) 

TreeSearchFunc デリゲートを書きたい場合は? どうやってするか?

4

1 に答える 1