#can you explain what effect this will

1 messages · Page 1 of 1 (latest)

tame linden
#

You're trying to prevent duplicates from being added to this Dictionary, right?

dawn ingot
#

yes but it s a list and I need to keep the right order when adding the items
so basically
you can imagine each node as a struct in code
in hlsl each struct can only use structs which are defined ontop of it in the file, currently it prints out stuff like this which is obviously incrorrect

struct Struct17{Struct19 Dependency;
}

struct Struct19{Struct20 Dependency;
}

struct Struct20{int x;
float y;
double z;
}

struct Struct15{Struct17 Dependency;
}

Since Struct 17 uses Struct 19 and therefore struct 20 which is defined below it, but before I think that it s inversed struct 15 uses struct 17 which is defined on top

tame linden
#

Alright so you add Struct17, and it's now element X.

By the time it goes to add another struct, right, if it sees a duplicate, you can tell it to not add that.

If it sees a duplicate you can tell it to return form the code right there. Or using continue to go on to the next loop.

dawn ingot
#

yep that s what I did, but the ordering is still wrong

tame linden
#

ahh so the next issue is that it's not in the order?

#

struct17 must be in 17th place? etc?

dawn ingot
#

hm not really struct 17 must be below struct 19 and struct 20 must be above all of them

tame linden
#

ahh re-ordering then

#

but I take it that when you add them to the list, initially, they're not guaranteed to be in order?

#

If you're trying to order the list after you add to it, you should be able to use LINQ

dawn ingot
#

if the solution I found interrests you this is what I ended up with, the issue was that I added the this pointer before adding the others therefore resulting in a wrong sorting order

 private ITypeInfo[] GetIndirectDependencies()
            {
                if(_indirectDependencies == null)
                {
                    List<ITypeInfo> indirectDependencies = new List<ITypeInfo>();
                    foreach (var dependency in DirectDependencies)
                    {
                        HlslNewTypeInfo casted = dependency as HlslNewTypeInfo;
                        if(casted != null)
                        {
                            indirectDependencies.AddRange(casted.
                            GetIndirectDependencies()
                            .Where(x => !indirectDependencies.Contains(x))
                            );
                        }
                    }
                    indirectDependencies.Add(this);
                    _indirectDependencies = indirectDependencies.ToArray();
                }
                return _indirectDependencies;
            }
tame linden
#

pardon my delay. Had to go to work.