English 中文(简体)
我是否需要通过假冒的<标准>、目标<标准>、目标>进行回收?
原标题:Will I need a recursive function to iterate through a Dictionary<String, Object> of Dictionary<String, Object>s?

还有许多层次,他们知道它会多么深 deep! 此外,请允许我就这个具体问题指出,另一个理论家的力量将是“理论”,我想要获得/修改的价值将是“信息”。

最佳回答

是否需要通过<代码>Dictionary<String, Object>Dictionary<String, Object>?

<><>>第号> 任何复读算法都可以改写,以使用明确分门,而不是打字。

这样做是否容易?

<>><>Perhaps>。 然而,如果这种结构根深蒂固(或包含周期),那么你就会冒着排他性超支的风险。

不收复的执行并非特别困难。 它将要求你保持一份名单(根据你希望访问儿童的顺序排列的顺序排列),以追踪尚未访问的次级法令。

一种非强制性的(不产生风险的)执行办法将涉及以下方面:

public IEnumerable<string> GetAllKeys( Dictionary<string,object> dictionary )
{
    var stackDictionariesToVisit = new Stack<Dictionary<string,object>>();

    stackDictionariesToVisit.Push( dictionary );

    // keep visiting iterating until the stack of dictionaries to visit is empty
    while( stackDictionariesToVisit.Count > 0 )
    {
        var nextDictionary = stackDictionariesToVisit.Pop();
        foreach( var keyValuePair in nextDictionary )
        {
            if( keyValuePair.Value is Dictionary<string,object> )
            {
                stackDictionariesToVisit.Push( 
                     keyValuePair.Value as Dictionary<string,object> );
            }
            else
            {
                yield return keyValuePair.Key;
            }
        }
    }
}

以上执行情况没有错误检查,也没有周期检查,而是用明确的分门别类取代再入侵。

www.un.org/Depts/DGACM/index_spanish.htm 为访问等级数据结构而选择采用(或不)再造,应取决于对所储存的数据类型的理解,而不是哪一种方法容易。 如果你有深厚的结构,你会利用再入侵更好地在NOT<>/em>附近,因为你可以控制你能够提供多少空间。 另一方面,如果你相信数据不会超过几个层次,那么(很显然)恢复执行可能会更容易理解和维持。

问题回答

基本上,是。 您必须用<代码>作为<<<>s>/code>加以测试,以测试你愿意通过哪几类产品来复制的每一种数值。

回收一般是向不明深度的树木结构转移最有条理的方法。 你们是否有某种理由可以采取报复行动? 它与你重新寻找其他选择一样,认为复算法不符合某些要求。

I am going to have to go with "yes" this would be the quickest and easiest to write. something like this....

string WalkIt( Dictionary<string,object> data )
{
    if ( data == null ) yield return null;

    foreach (KeyValuePair<string, object> kvp in data)
    {
        if (kvp.Value is string)
        {
            yield return kvp.Value;
        }

        if (kvp.Value is Dictionary<string, object>)
        {
            foreach( string str in walk(kvp.Value as Dictionary<string, object>))
                 yield return str;
        }
            }
        }
       yield return null;
}

这样做并不必要。 如)能够找到几乎所有的树木。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...