Exemplo n.º 1
0
		static Entity[] GetClosure(Resource[] starts, Hashtable table) {
			ResSet ret = new ResSet();
			ResSet toadd = new ResSet(starts);
			while (toadd.Count > 0) {
				ResSet newadd = new ResSet();
				
				foreach (Resource e in toadd) {
					if (!(e is Entity)) continue;
					if (ret.Contains(e)) continue;
					ret.Add(e);
					if (table.ContainsKey(e))
						newadd.AddRange((ResSet)table[e]);
				}
				
				toadd.Clear();
				toadd.AddRange(newadd);
			}
			return ret.ToEntityArray();
		}
Exemplo n.º 2
0
		static Entity[] GetClosure(Resource[] starts, Hashtable table, bool includeStarts) {
			ResSet ret = new ResSet();
			ResSet toadd = new ResSet(starts);
			bool firstRound = true;
			while (toadd.Count > 0) {
				ResSet newadd = new ResSet();
				
				foreach (Resource e in toadd) {
					if (!(e is Entity)) continue;
					if (ret.Contains(e)) continue;
					if (!(firstRound && !includeStarts)) ret.Add(e);
					if (table.ContainsKey(e))
						newadd.AddRange((ResSet)table[e]);
				}
				
				toadd.Clear();
				toadd.AddRange(newadd);
				firstRound = false;
			}
			return ret.ToEntityArray();
		}