Ejemplo n.º 1
0
 public void AddExample()
 {
     var whatAnimalEatHashList = new HashList<string, string>();
     whatAnimalEatHashList.Add("cat", "milk");
     whatAnimalEatHashList.Add("cat", "fish");
     whatAnimalEatHashList.Add("dog", "dog food");
     whatAnimalEatHashList.Add("dog", "bones");
     whatAnimalEatHashList.Add("tiger", "people");
     // There should be 3 items.
     Assert.AreEqual(3, whatAnimalEatHashList.Count);
 }
Ejemplo n.º 2
0
        public void AddParamsExample()
        {
            var whatAnimalEatHashList = new HashList<string, string>();
            whatAnimalEatHashList.Add("cat", "milk", "fish");
            whatAnimalEatHashList.Add("dog", "dog food", "bones");
            whatAnimalEatHashList.Add("tiger", "people");

            // There are 3 keys.
            Assert.AreEqual(3, whatAnimalEatHashList.KeyCount);

            // There are 5 values.
            Assert.AreEqual(5, whatAnimalEatHashList.ValueCount);
        }
Ejemplo n.º 3
0
		public override PathCond Or(PathCond other) {
			if (other is CachedAtom && conds.Contains(((CachedAtom)other).Negate())) {
				// Reduce Or(OR(...,e,...), NOT(e)) and Or(OR(...,NOT(e),...), e) to TRUE
				return TRUE;
			}
			else if (other is Disj) {
				HashList<PathCond> result = new HashList<PathCond>();
				result.AddAll(conds);
				foreach (PathCond cond in ((Disj)other).conds) {
					if (cond is CachedAtom && conds.Contains((cond as CachedAtom).Negate())) {
						// Reduce Or(OR(...,e,...),OR(...,NOT(e),...)) to TRUE
						// and    Or(OR(...,NOT(e),...),OR(...,e,...)) to TRUE
						return TRUE;
					}
					result.Add(cond);
				}
				return Disj.Make(result.ToArray());
			}
			else if (other is Conj) {
				if (((Conj)other).conds.Contains(this)) {
					// Reduce (pi | (p1 & ... & pn)) to pi
					return this;
				}
				else {
					if (((Conj)other).conds.Any(cond => conds.Contains(cond))) {
						return this;
					}
				}
				return Disj.Make(AddItem(this.conds, other));
			}
			else {
				return Disj.Make(AddItem(this.conds, other));
			}
		}
Ejemplo n.º 4
0
        public void Simple()
        {
            var hashList = new HashList<int, string> {{2, "a"}};

            Assert.AreEqual(hashList.ValueCount, 1);
            Assert.AreEqual(hashList.KeyCount, 1);

            hashList.Add(4, new List<string>(new[] { "2", "3", "4", "5" }));

            Assert.AreEqual(hashList.ValueCount, 5);
            Assert.AreEqual(hashList.KeyCount, 2);

            var enumerator = hashList.GetValueEnumerator();

            var list = new List<string>();

            while (enumerator.MoveNext())
            {
                list.Add(enumerator.Current);
            }

            Assert.AreEqual(list.Count, 5);
            Assert.IsTrue(list.Contains("a"));
            Assert.IsTrue(list.Contains("2"));
            Assert.IsTrue(list.Contains("3"));
            Assert.IsTrue(list.Contains("4"));
            Assert.IsTrue(list.Contains("5"));
        }
Ejemplo n.º 5
0
        public void Params()
        {
            var hashList = new HashList<int, string>
                               {
                                   {2, "a", "b"}
                               };

            Assert.AreEqual(hashList.ValueCount, 2);
            Assert.AreEqual(hashList.KeyCount, 1);

            hashList.Add(4, "2", "3", "4", "5");

            Assert.AreEqual(hashList.ValueCount, 6);
            Assert.AreEqual(hashList.KeyCount, 2);

            hashList.Add(2, "2", "3", "4", "5");

            Assert.AreEqual(hashList.ValueCount, 10);
            Assert.AreEqual(hashList.KeyCount, 2);
        }
Ejemplo n.º 6
0
        public void Simple()
        {
            var hashList = new HashList<int, string>
                               {
                                   {2, "a"}
                               };

            Assert.AreEqual(hashList.ValueCount, 1);
            Assert.AreEqual(hashList.KeyCount, 1);

            hashList.Add(4, new List<string>(new[] { "2", "3", "4", "5" }));

            Assert.AreEqual(hashList.ValueCount, 5);
            Assert.AreEqual(hashList.KeyCount, 2);

            hashList.Add(2, new List<string>(new[] { "2", "3", "4", "5" }));

            Assert.AreEqual(hashList.ValueCount, 9);
            Assert.AreEqual(hashList.KeyCount, 2);
        }
Ejemplo n.º 7
0
		public static PathCond Make(params PathCond[] conjs) {
			HashList<PathCond> result = new HashList<PathCond>();
			foreach (PathCond conj in conjs) {
				if (conj.Is(false)) {
					return FALSE;
				}
				else if (!conj.Is(true)) {
					result.Add(conj);
				}
			}
			if (result.Count == 0) {
				return TRUE;
			}
			else if (result.Count == 1) {
				return result.Single();
			}
			else {
				return new Conj(result.ToArray());
			}
		}
Ejemplo n.º 8
0
    // Use this for initialization
    void Start ()
    {
        list = new List<HashList<int>>();
        for (int i = 0; i < 1000; i++)
        {
            var hash = new HashList<int>(15000);
            for (int j = 0; j < 10000; j++)
            {
                hash.Add(Random.Range(int.MinValue, int.MaxValue));
            }
        }

        var set = new HashList<int>();
        Debug.Log("Add 1 " + set.Add(1));
        Debug.Log("Add 1 " + set.Add(1));
        set.Add(30000);
        set.Add(444);
        Debug.Log("Add 5555 " + set.Add(5555));
        set.Add(500000);
        set.Add(364892679);

        set.Remove(444);
        Debug.Log("Set contains 444 = " + set.Contains(444));
        Debug.Log("Size = " + set.Count);

        foreach (var i in set)
        {
            Debug.Log("Set contains " + i + " = " + set.Contains(i));
        }


        Debug.Log("Set contains 11 = " + set.Contains(11));
        Debug.Log("Set contains 23 = " + set.Contains(23));
        Debug.Log("Set contains 16 = " + set.Contains(16));
        Debug.Log("Set contains 32 = " + set.Contains(32));
        Debug.Log("Set contains 33 = " + set.Contains(33));
    }
Ejemplo n.º 9
0
 internal void Add(ArbiterKey key, Arbiter arbiter)
 {
     keysSortedList.Add(key);
     dictionaryKeys.Add(key, arbiter);
 }
        private void Change(BuildAssembly assembly)
        {
            var module  = (BuildModule)assembly.Module;
            var strings = new HashList <string>();

            MainType.Create(assembly);

            if (assembly.EncryptIL)
            {
                strings.Add(".");                 // Dot is at index 0
            }
            if (_evaluationPeriodInDays > 0)
            {
                module.MainType.GenerateCheckForExpiredEvaluation(_evaluationPeriodInDays);
            }

            if (assembly.StripObfuscationAttributeExists)
            {
                ObfuscationAttributeStripper.Strip(assembly);
            }

            if (assembly.SuppressILdasm)
            {
                CA.SuppressIldasmAttribute.AddIfNotExists(assembly.CustomAttributes);
            }

            if (assembly.RenameMembers || assembly.DevirtualizeMethods)
            {
                ExplicitMethodCallBuilder.Build(assembly);
            }

            if (CancellationPending)
            {
                return;
            }

            if (_renameAssemblies)
            {
                MemberRenameHelper.BuildRenamedAssemblyResolver(assembly, _renamedAssemblyNames);
            }

            if (assembly.HasWpfResource && (_renameAssemblies || _renameMembers))
            {
                BamlMemberReferenceMapper.Map(assembly, _log);
            }

            if (assembly.HasWpfResource && _renameAssemblies)
            {
                ResourceHelper.RenameWpfResource(assembly);
            }

            if (_renameAssemblies)
            {
                ResourceHelper.RenameSatelliteAssemblies(assembly);
            }

            if (assembly.ObfuscateResources)
            {
                ResourceObfuscator.Obfuscate(assembly);
            }

            if (_obfuscateResources)
            {
                ResourceResolverGenerator.Generate(assembly);
            }

            if (assembly.ObfuscateStrings)
            {
                StringObfuscator.Obfuscate(assembly, strings);
            }

            if (CancellationPending)
            {
                return;
            }

            if (assembly.SealTypes)
            {
                TypeSealer.Seal(assembly);
            }

            if (assembly.DevirtualizeMethods)
            {
                MethodDevirtualizer.Devirtualize(assembly);
            }

            if (CancellationPending)
            {
                return;
            }

            if (_renameMembers)
            {
                ExplicitMethodOverrideBuilder.Build(assembly, _nameGenerator);
            }

            if (_encryptIL)
            {
                ILCryptoMapper.Map(assembly);
            }

            if (assembly.EncryptIL)
            {
                ILCryptoObfuscator.Obfuscate(assembly, strings);
            }

            if (CancellationPending)
            {
                return;
            }

            if (assembly.RemoveUnusedMembers)
            {
                Stripper.Strip(assembly);
            }

            if (assembly.ObfuscateControlFlow)
            {
                ControlFlowObfuscator.Obfuscate(assembly, true);
            }

            if (strings.Count > 0)
            {
                StringLoaderGenerator.Generate(assembly, strings);
            }

            if (CancellationPending)
            {
                return;
            }

            // From this point no more code can be added.

            MainType.Generate(assembly);
            DelegateTypeGenerator.Generate(assembly);
            GeneratedCodeObfuscator.Obfuscate(assembly, _nameGenerator);

            if (CancellationPending)
            {
                return;
            }

            ILCryptoBlobBuilder.MapMemberReferences(assembly);
            MemberReferenceMapper.Map(assembly);
            MemberNameChanger.Change(assembly);

            if (CancellationPending)
            {
                return;
            }

            assembly.Compile();

            Scavenge();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Create an automatic constructor to set all fields
        /// </summary>
        /// <param name="type">Type node</param>
        private void GenerateAutoCtor(TypeNode type)
        {
            var node = new MethodNode(".ctor", new SignatureNode("void"), false);

              var parameters = new HashList<ParameterNode>();
              int idx = 0;
              foreach(var curr in type.Fields)
              {
            var param = new ParameterNode("_" + curr, type.Fields[curr].Type, idx);
            parameters.Add("_" + curr, param);
            idx++;

            var assignNode = new IdentifierSetNode(curr, true);
            assignNode.Expression = new IdentifierGetNode("_" + curr);
            node.Body.Statements.Add(assignNode);
              }

              node.SetParameters(parameters);
              node.Owner = type;
              AddMethod(type, node);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Create an automatic .Equal() method
        /// </summary>
        /// <param name="type">Type node</param>
        private void GenerateAutoComparator(TypeNode type)
        {
            var node = new MethodNode("equal", new SignatureNode("bool"), false);

              // define parameter
              var parameters = new HashList<ParameterNode>();
              var param = new ParameterNode("_obj", new SignatureNode(type.Name), 0);
              parameters.Add(param.Name, param);

              // generate series of comparisons
              foreach(var curr in type.Fields)
              {
            //
            // if(@<name> != _obj.<name>) return false;
            //
            node.Body.Statements.Add(
              Expr.If(
            Expr.Compare(
              Expr.IdentifierGet(curr, true),
              Lexer.LexemType.NotEqual,
              Expr.IdentifierGet(curr, Expr.IdentifierGet("_obj"))
            ),
            Expr.Return(
              Expr.Bool(true)
            )
              )
            );
              }

              // return true
              node.Body.Statements.Add(
            Expr.Return(
              Expr.Bool(true)
            )
              );

              node.SetParameters(parameters);
              node.Owner = type;
              AddMethod(type, node);
        }
Ejemplo n.º 13
0
        public void Simple()
        {
            var hashList = new HashList<int, string> {{2, "a"}};

            Assert.AreEqual(hashList.ValueCount, 1);
            Assert.AreEqual(hashList.KeyCount, 1);

            hashList.Add(4, new List<string>(new[] { "2", "3", "4", "5" }));

            Assert.AreEqual(hashList.ValueCount, 5);
            Assert.AreEqual(hashList.KeyCount, 2);

            Assert.IsTrue(hashList.Remove(2));
            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 4);

            Assert.IsFalse(hashList.Remove(2));
            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 4);

            Assert.IsTrue(hashList.RemoveValue("2"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            Assert.IsFalse(hashList.Remove(3, "2"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            Assert.IsFalse(hashList.Remove(4, "2"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            Assert.IsTrue(hashList.Remove(4, "5"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 2);

            hashList.Add(4, "4");

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            hashList.RemoveAll("4");

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 1);

            Assert.IsFalse(hashList.Remove(10));

            hashList.Add(4, "5");
            hashList.Add(4, "6");

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            Assert.IsTrue(hashList.RemoveValue("5"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 2);

            Assert.IsFalse(hashList.RemoveValue("5"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 2);
        }
Ejemplo n.º 14
0
        public void Add_Valid_Adds()
        {
            hashList.Add(new Dummy());

            Assert.IsNotEmpty(hashList);
        }
        public void DefineGetAllInstancesMethod(TypeDefinition containerType, ModuleDefinition module, 
            IDictionary<IDependency, IImplementation> serviceMap)
        {
            var targetMethods = new List<MethodDefinition>();
            foreach (MethodDefinition method in containerType.Methods)
            {
                if (method.Name != "GetAllInstances")
                    continue;

                targetMethods.Add(method);
            }

            var getAllInstancesMethod = targetMethods[0];

            // Remove the stub implementation
            var body = getAllInstancesMethod.Body;
            var IL = body.GetILProcessor();

            body.InitLocals = true;
            body.Instructions.Clear();

            var listVariable = getAllInstancesMethod.AddLocal<List<object>>();
            var listCtor = module.ImportConstructor<List<object>>();
            IL.Emit(OpCodes.Newobj, listCtor);
            IL.Emit(OpCodes.Stloc, listVariable);

            // Group the dependencies by type
            var dependenciesByType = new HashList<System.Type, IDependency>();
            foreach (var dependency in serviceMap.Keys)
            {
                var serviceType = dependency.ServiceType;
                dependenciesByType.Add(serviceType, dependency);
            }

            var getTypeFromHandleMethod = typeof(System.Type).GetMethod("GetTypeFromHandle", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
            var getTypeFromHandle = module.Import(getTypeFromHandleMethod);
            var addItem = module.ImportMethod<List<object>>("Add");

            var currentService = getAllInstancesMethod.AddLocal<object>();

            foreach (var currentType in dependenciesByType.Keys)
            {
                var currentTypeRef = module.Import(currentType);

                var currentList = dependenciesByType[currentType];
                if (currentList.Count == 0)
                    continue;

                var skipAdd = IL.Create(OpCodes.Nop);
                IL.Emit(OpCodes.Ldarg_1);
                IL.Emit(OpCodes.Ldtoken, currentTypeRef);
                IL.Emit(OpCodes.Call, getTypeFromHandle);
                IL.Emit(OpCodes.Ceq);
                IL.Emit(OpCodes.Brfalse, skipAdd);

                foreach (var dependency in currentList)
                {
                    IL.Emit(OpCodes.Ldloc, listVariable);

                    var implementation = serviceMap[dependency];
                    implementation.Emit(dependency, serviceMap, getAllInstancesMethod);

                    IL.Emit(OpCodes.Stloc, currentService);

                    // Call IInitialize.Initialize(container) on the current service type
                    _initializer.Initialize(IL, module, currentService);

                    IL.Emit(OpCodes.Ldloc, currentService);
                    IL.Emit(OpCodes.Callvirt, addItem);
                }

                IL.Append(skipAdd);
            }

            var skipOtherContainerCall = IL.Create(OpCodes.Nop);

            var getNextContainer = module.ImportMethod<IMicroContainer>("get_NextContainer");
            var otherContainer = getAllInstancesMethod.AddLocal<IMicroContainer>();

            // var otherContainer = this.NextContainer;
            IL.Emit(OpCodes.Ldarg_0);
            IL.Emit(OpCodes.Callvirt, getNextContainer);
            IL.Emit(OpCodes.Stloc, otherContainer);

            // if (otherContainer != null && this != otherContainer) {
            IL.Emit(OpCodes.Ldloc, otherContainer);
            IL.Emit(OpCodes.Brfalse, skipOtherContainerCall);

            IL.Emit(OpCodes.Ldloc, otherContainer);
            IL.Emit(OpCodes.Ldarg_0);
            IL.Emit(OpCodes.Ceq);
            IL.Emit(OpCodes.Brtrue, skipOtherContainerCall);

            // var otherInstances = NextContainer.GetAllInstances(type);
            var otherGetAllInstancesMethod = module.ImportMethod<IMicroContainer>("GetAllInstances");

            IL.Emit(OpCodes.Ldloc, listVariable);
            IL.Emit(OpCodes.Ldloc, otherContainer);
            IL.Emit(OpCodes.Ldarg_1);
            IL.Emit(OpCodes.Callvirt, otherGetAllInstancesMethod);

            // resultList.AddRange(otherInstances);
            var addRangeMethod = module.ImportMethod<List<object>>("AddRange");
            IL.Emit(OpCodes.Callvirt, addRangeMethod);

            // }

            // Cast the results down to an IEnumerable<object>
            var enumerableType = module.ImportType<IEnumerable<object>>();
            IL.Append(skipOtherContainerCall);
            IL.Emit(OpCodes.Ldloc, listVariable);
            IL.Emit(OpCodes.Isinst, enumerableType);
            IL.Emit(OpCodes.Ret);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Creates a new method with argument types given by function arguments.
        /// </summary>
        internal MethodEntity CreateMethod(string name, TypeSignature returnType, IEnumerable<FunctionArgument> args = null, bool isStatic = false, bool isVirtual = false, bool prepare = false)
        {
            var argHash = new HashList<FunctionArgument>();
            if(args != null)
                foreach (var curr in args)
                    argHash.Add(curr.Name, curr);

            var me = createMethodCore(name, isStatic, isVirtual, prepare);
            me.ReturnTypeSignature = returnType;
            me.Arguments = argHash;
            return me;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Find or create an output file for a corresponding input file
        /// </summary>
        /// <param name="InputFile">The input file</param>
        /// <param name="IncludeStack">The current include stack</param>
        /// <param name="OutputFiles">List of output files</param>
        /// <param name="OutputFileLookup">Mapping from source file to output file</param>
        /// <returns>The new or existing output file</returns>
        static OutputFile FindOrCreateOutputFile(List <SourceFile> InputFileStack, Dictionary <SourceFile, SourceFile> CppFileToHeaderFile, HashList <OutputFile> PreviousFiles, Dictionary <SourceFile, OutputFile> OutputFileLookup, Dictionary <Symbol, OutputFile> FwdSymbolToHeader, bool bMakeStandalone, bool bUseOriginalIncludes, TextWriter Log)
        {
            // Get the file at the top of the stack
            SourceFile InputFile = InputFileStack[InputFileStack.Count - 1];

            // Try to find an existing file
            OutputFile OutputFile;

            if (OutputFileLookup.TryGetValue(InputFile, out OutputFile))
            {
                if (OutputFile == null)
                {
                    throw new Exception("Circular include dependencies are not allowed.");
                }
                foreach (OutputFile IncludedFile in OutputFile.OriginalIncludedFiles.Where(x => !PreviousFiles.Contains(x)))
                {
                    PreviousFiles.Add(IncludedFile);
                }
            }
            else
            {
                // Add a placeholder entry in the output file lookup, so we can detect circular include dependencies
                OutputFileLookup[InputFile] = null;

                // Duplicate the list of previously included files, so we can construct the
                List <OutputFile> PreviousFilesCopy = new List <OutputFile>(PreviousFiles);

                // Build a list of includes for this file. First include is a placeholder for any missing includes that need to be inserted.
                List <OutputFileInclude> Includes = new List <OutputFileInclude>();
                if ((InputFile.Flags & SourceFileFlags.External) == 0)
                {
                    for (int MarkupIdx = 0; MarkupIdx < InputFile.Markup.Length; MarkupIdx++)
                    {
                        PreprocessorMarkup Markup = InputFile.Markup[MarkupIdx];
                        if (Markup.IsActive && Markup.IncludedFile != null && (Markup.IncludedFile.Flags & SourceFileFlags.Inline) == 0 && Markup.IncludedFile.Counterpart == null)
                        {
                            InputFileStack.Add(Markup.IncludedFile);
                            OutputFile IncludeFile = FindOrCreateOutputFile(InputFileStack, CppFileToHeaderFile, PreviousFiles, OutputFileLookup, FwdSymbolToHeader, bMakeStandalone, bUseOriginalIncludes, Log);
                            InputFileStack.RemoveAt(InputFileStack.Count - 1);
                            Includes.Add(new OutputFileInclude(MarkupIdx, IncludeFile));
                        }
                    }
                }

                // Find the matching header file
                OutputFile HeaderFile = null;
                if ((InputFile.Flags & SourceFileFlags.TranslationUnit) != 0)
                {
                    SourceFile CandidateHeaderFile;
                    if (CppFileToHeaderFile.TryGetValue(InputFile, out CandidateHeaderFile) && (CandidateHeaderFile.Flags & SourceFileFlags.Standalone) != 0)
                    {
                        OutputFileLookup.TryGetValue(CandidateHeaderFile, out HeaderFile);
                    }
                }

                // Create the output file.
                if ((InputFile.Flags & SourceFileFlags.Output) != 0 && !bUseOriginalIncludes)
                {
                    OutputFile = CreateOptimizedOutputFile(InputFile, HeaderFile, PreviousFilesCopy, Includes, InputFileStack, FwdSymbolToHeader, bMakeStandalone, Log);
                }
                else
                {
                    OutputFile = CreatePassthroughOutputFile(InputFile, Includes, Log);
                }

                // Replace the null entry in the output file lookup that we added earlier
                OutputFileLookup[InputFile] = OutputFile;

                // Add this file to the list of included files
                PreviousFiles.Add(OutputFile);

                // If the output file dependends on something on the stack, make sure it's marked as pinned
                if ((InputFile.Flags & SourceFileFlags.Pinned) == 0)
                {
                    SourceFragment Dependency = OutputFile.Dependencies.FirstOrDefault(x => InputFileStack.Contains(x.File) && x.File != InputFile);
                    if (Dependency != null)
                    {
                        throw new Exception(String.Format("'{0}' is not marked as pinned, but depends on '{1}' which includes it", InputFile.Location.GetFileName(), Dependency.UniqueName));
                    }
                }
            }
            return(OutputFile);
        }
Ejemplo n.º 18
0
 public void add(String name, Figura f)
 {
     objects.Add(name, f);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="InputFile">The input file that this output file corresponds to</param>
        public OutputFile(SourceFile InputFile, OutputFile HeaderFile, IEnumerable <OutputFile> PreviousFiles, List <OutputFileInclude> Includes, List <SourceFile> InputFileStack, Dictionary <Symbol, OutputFile> FwdSymbolToHeader, bool bMakeStandalone, TextWriter Log)
        {
            this.InputFile = InputFile;
            this.Includes  = Includes;
            Debug.Assert(HeaderFile == null || (InputFile.Flags & SourceFileFlags.TranslationUnit) != 0);

            // Traverse through all the included headers, figuring out the first unique include for each file and fragment
            HashSet <OutputFile>     VisitedFiles     = new HashSet <OutputFile>();
            HashSet <SourceFragment> VisitedFragments = new HashSet <SourceFragment>();

            // Go through the standalone headers first
            OutputFile MonolithicHeader = null;

            if (HeaderFile == null && (InputFile.Flags & SourceFileFlags.Standalone) != 0 && (InputFile.Flags & SourceFileFlags.External) == 0 && (InputFile.Flags & SourceFileFlags.Aggregate) == 0)
            {
                // Insert a dummy include to receive all the inserted headers
                OutputFileInclude ImplicitInclude = new OutputFileInclude(-1, null);
                ImplicitInclude.ExpandedReferences = new List <OutputFileReference>();
                Includes.Insert(0, ImplicitInclude);

                // Determine which monolithic header to use
                IEnumerable <OutputFile> PotentialMonolithicHeaders = PreviousFiles.Union(Includes.Select(x => x.TargetFile).Where(x => x != null).SelectMany(x => x.IncludedFiles));
                if (InputFile.Module != null && InputFile.Module.PublicDependencyModules.Union(InputFile.Module.PrivateDependencyModules).Any(x => x.Name == "Core"))
                {
                    MonolithicHeader = PotentialMonolithicHeaders.FirstOrDefault(x => (x.InputFile.Flags & SourceFileFlags.IsCoreMinimal) != 0);
                }
                else
                {
                    MonolithicHeader = PotentialMonolithicHeaders.FirstOrDefault(x => (x.InputFile.Flags & SourceFileFlags.IsCoreTypes) != 0);
                }

                // Update the dependencies to treat all the contents of a monolithic header as pinned
                if (MonolithicHeader != null)
                {
                    SourceFragment[] UniqueFragments = MonolithicHeader.IncludedFragments.Except(VisitedFragments).ToArray();
                    ImplicitInclude.ExpandedReferences.Add(new OutputFileReference(MonolithicHeader, UniqueFragments));
                    VisitedFragments.UnionWith(UniqueFragments);
                    VisitedFiles.Add(MonolithicHeader);
                }

                // Insert all the forward declaration headers, but only treat them as supplying the forward declarations themselves. They may happen to include
                // some utility classes (eg. TSharedPtr), and we don't want to include an unrelated header to satisfy that dependency.
                foreach (OutputFile FwdHeader in FwdSymbolToHeader.Values)
                {
                    FindExpandedReferences(FwdHeader, ImplicitInclude.ExpandedReferences, VisitedFiles, VisitedFragments, true);
                }

                // Add all the other files
                if (bMakeStandalone)
                {
                    foreach (OutputFile PreviousFile in PreviousFiles)
                    {
                        if ((PreviousFile.InputFile.Flags & SourceFileFlags.Inline) == 0 && (PreviousFile.InputFile.Flags & SourceFileFlags.Pinned) == 0 && VisitedFiles.Add(PreviousFile))
                        {
                            SourceFragment[] UniqueFragments = PreviousFile.IncludedFragments.Except(VisitedFragments).ToArray();
                            ImplicitInclude.ExpandedReferences.Add(new OutputFileReference(PreviousFile, UniqueFragments));
                            VisitedFragments.UnionWith(UniqueFragments);
                        }
                    }
                }
            }

            // Figure out a list of files which are uniquely reachable through each include. Force an include of the matching header as the first thing.
            foreach (OutputFileInclude Include in Includes)
            {
                if (Include.ExpandedReferences == null)
                {
                    Include.ExpandedReferences = new List <OutputFileReference>();
                    if (Include == Includes[0] && HeaderFile != null)
                    {
                        Include.ExpandedReferences.Add(new OutputFileReference(HeaderFile, HeaderFile.IncludedFragments));
                        VisitedFragments.UnionWith(HeaderFile.IncludedFragments);
                    }
                    FindExpandedReferences(Include.TargetFile, Include.ExpandedReferences, VisitedFiles, VisitedFragments, true);
                }
            }

            // Find all the symbols which are referenced by this file
            HashSet <SourceFragment> FragmentsWithReferencedSymbols = new HashSet <SourceFragment>();

            foreach (SourceFragment Fragment in InputFile.Fragments)
            {
                foreach (KeyValuePair <Symbol, SymbolReferenceType> ReferencedSymbol in Fragment.ReferencedSymbols)
                {
                    if (ReferencedSymbol.Value == SymbolReferenceType.RequiresDefinition)
                    {
                        FragmentsWithReferencedSymbols.Add(ReferencedSymbol.Key.Fragment);
                    }
                }
            }

            // Aggregate headers are designed to explicitly include headers from the current module. Expand out a list of them, so they can be included when encountered.
            HashSet <OutputFile> ExplicitIncludes = new HashSet <OutputFile>();

            if ((InputFile.Flags & SourceFileFlags.Aggregate) != 0)
            {
                foreach (OutputFileInclude Include in Includes)
                {
                    ExplicitIncludes.UnionWith(Include.ExpandedReferences.Where(x => x.File.InputFile.Location.IsUnderDirectory(InputFile.Location.Directory)).Select(x => x.File));
                }
                foreach (OutputFileInclude Include in Includes)
                {
                    ExplicitIncludes.Remove(Include.TargetFile);
                }
            }

            // Create the list of remaining dependencies for this file, and add any forward declarations
            Dependencies = new HashSet <SourceFragment>();
            AddForwardDeclarations(InputFile, ForwardDeclarations, Dependencies, FwdSymbolToHeader);

            // Reduce the list of includes to those that are required.
            for (int FragmentIdx = InputFile.Fragments.Length - 1, IncludeIdx = Includes.Count - 1; FragmentIdx >= 0; FragmentIdx--)
            {
                // Update the dependency lists for this fragment
                SourceFragment InputFragment = InputFile.Fragments[FragmentIdx];
                if (InputFragment.Dependencies != null)
                {
                    Dependencies.UnionWith(InputFragment.Dependencies);
                }
                Dependencies.Remove(InputFragment);

                // Scan backwards through the list of includes, expanding each include to those which are required
                int MarkupMin = (FragmentIdx == 0)? -1 : InputFragment.MarkupMin;
                for (; IncludeIdx >= 0 && Includes[IncludeIdx].MarkupIdx >= MarkupMin; IncludeIdx--)
                {
                    OutputFileInclude Include = Includes[IncludeIdx];

                    // Always include the same header for aggregates
                    if ((InputFile.Flags & SourceFileFlags.Aggregate) != 0)
                    {
                        Include.FinalFiles.Insert(0, Include.TargetFile);
                        Dependencies.ExceptWith(Include.TargetFile.IncludedFragments);
                        Dependencies.UnionWith(Include.TargetFile.Dependencies);
                    }

                    // Include any indirectly included files
                    for (int Idx = Include.ExpandedReferences.Count - 1; Idx >= 0; Idx--)
                    {
                        // Make sure we haven't already added it above
                        OutputFileReference Reference = Include.ExpandedReferences[Idx];
                        if (!Include.FinalFiles.Contains(Reference.File))
                        {
                            if (Dependencies.Any(x => Reference.UniqueFragments.Contains(x)) ||
                                (Reference.File.InputFile.Flags & SourceFileFlags.Pinned) != 0 ||
                                Reference.File == HeaderFile ||
                                Reference.File == MonolithicHeader ||
                                ExplicitIncludes.Contains(Reference.File) ||
                                ((InputFile.Flags & SourceFileFlags.Aggregate) != 0 && Reference.File == Include.TargetFile) ||                                 // Always include the original header for aggregates. They are written explicitly to include certain files.
                                Reference.UniqueFragments.Any(x => FragmentsWithReferencedSymbols.Contains(x)))
                            {
                                Include.FinalFiles.Insert(0, Reference.File);
                                Dependencies.ExceptWith(Reference.File.IncludedFragments);
                                Dependencies.UnionWith(Reference.File.Dependencies);
                            }
                        }
                    }
                }
            }

            // Remove any includes that are already included by the matching header
            if (HeaderFile != null)
            {
                HashSet <OutputFile> HeaderIncludedFiles = new HashSet <OutputFile>(HeaderFile.Includes.SelectMany(x => x.FinalFiles));
                foreach (OutputFileInclude Include in Includes)
                {
                    Include.FinalFiles.RemoveAll(x => HeaderIncludedFiles.Contains(x));
                }
            }

            // Check that all the dependencies have been satisfied
            if (Dependencies.Count > 0)
            {
                // Find those which are completely invalid
                List <SourceFragment> InvalidDependencies = Dependencies.Where(x => !InputFileStack.Contains(x.File)).ToList();
                if (InvalidDependencies.Count > 0)
                {
                    Log.WriteLine("warning: {0} does not include {1}; may have missing dependencies.", InputFile, String.Join(", ", InvalidDependencies.Select(x => x.Location.FullName)));
                }
                Dependencies.ExceptWith(InvalidDependencies);

                // Otherwise warn about those which were not pinned
                foreach (SourceFile DependencyFile in Dependencies.Select(x => x.File))
                {
                    Log.WriteLine("warning: {0} is included by {1} ({2}), but depends on it and should be marked as pinned.", InputFile, DependencyFile, String.Join(" -> ", InputFileStack.SkipWhile(x => x != DependencyFile).Select(x => x.Location.GetFileName())));
                }

                // Mark it as non-standalone and pinned
                InputFile.Flags = (InputFile.Flags | SourceFileFlags.Pinned) & ~SourceFileFlags.Standalone;
            }

            // Do one more forward pass through all the headers, and remove anything that's included more than once. That can happen if we have a referenced symbol as well as
            // an explicit include, for example.
            HashSet <OutputFile> FinalIncludes = new HashSet <OutputFile>();

            foreach (OutputFileInclude Include in Includes)
            {
                for (int Idx = 0; Idx < Include.FinalFiles.Count; Idx++)
                {
                    if (!FinalIncludes.Add(Include.FinalFiles[Idx]))
                    {
                        Include.FinalFiles.RemoveAt(Idx);
                        Idx--;
                    }
                }
            }

            // Build the list of satisfied dependencies
            IncludedFragments = new HashSet <SourceFragment>();
            IncludedFragments.UnionWith(Includes.SelectMany(x => x.FinalFiles).SelectMany(x => x.IncludedFragments));
            IncludedFragments.UnionWith(InputFile.Fragments);

            // Build the list of all the included files, so other output files that include it can expand it out.
            IncludedFiles = new HashList <OutputFile>();
            IncludedFiles.UnionWith(Includes.SelectMany(x => x.FinalFiles).SelectMany(x => x.IncludedFiles));
            IncludedFiles.Add(this);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Calculate the route from start to end.
        /// </summary>
        /// <param name="start">Start.</param>
        /// <param name="end">End.</param>
        public void Route(T start, T end, List <T> route)
        {
            route.Clear();
            if (start == null || end == null)
            {
                return;
            }

            for (int i = 0, nodesLength = nodes.Length; i < nodesLength; i++)
            {
                var s = nodes[i];
                g[s]      = 0f;
                parent[s] = null;
                inPath[s] = false;
            }
            openset.Clear();
            closedset.Clear();
            path.Clear();

            var current = start;

            openset.Add(current);
            while (openset.Count > 0)
            {
                current = openset[0];
                for (var i = 1; i < openset.Count; i++)
                {
                    var d = g[current].CompareTo(g[openset[i]]);
                    if (d < 0)
                    {
                        current = openset[i];
                    }
                }
                //openset.Sort ((a,b) => g [a].CompareTo (g [b]));
                current = openset[0];
                if (current == end)
                {
                    while (parent[current] != null)
                    {
                        path.Enqueue(current);
                        inPath[current] = true;
                        current         = parent[current];
                        if (path.Count >= nodes.Length)
                        {
                            return;
                        }
                    }
                    inPath[current] = true;
                    path.Enqueue(current);
                    while (path.Count > 0)
                    {
                        route.Add(path.Dequeue());
                    }
                    return;
                }
                openset.Remove(current);
                closedset.Add(current);
                var connectedNodes = current.GetConnectedNodes();
                for (int i = 0, connectedNodesCount = connectedNodes.Count; i < connectedNodesCount; i++)
                {
                    var node = connectedNodes[i];
                    if (closedset.Contains(node))
                    {
                        continue;
                    }
                    if (openset.Contains(node))
                    {
                        var new_g = g[current] + current.CalculateMoveCost(node);
                        if (g[node] > new_g)
                        {
                            g[node]      = new_g;
                            parent[node] = current;
                        }
                    }
                    else
                    {
                        g[node]      = g[current] + current.CalculateMoveCost(node);
                        parent[node] = current;
                        openset.Add(node);
                    }
                }
            }
            return;
        }
Ejemplo n.º 21
0
        private void CollisionDetected(RigidBody body1, RigidBody body2, TSVector point1, TSVector point2, TSVector normal, FP penetration)
        {
            bool anyBodyColliderOnly = body1.IsColliderOnly || body2.IsColliderOnly;

            Arbiter    arbiter            = null;
            ArbiterMap selectedArbiterMap = null;

            if (anyBodyColliderOnly)
            {
                selectedArbiterMap = arbiterTriggerMap;
            }
            else
            {
                selectedArbiterMap = arbiterMap;
            }

            bool arbiterCreated = false;

            lock (selectedArbiterMap) {
                selectedArbiterMap.LookUpArbiter(body1, body2, out arbiter);
                if (arbiter == null)
                {
                    arbiter       = Arbiter.Pool.GetNew();
                    arbiter.body1 = body1; arbiter.body2 = body2;
                    selectedArbiterMap.Add(new ArbiterKey(body1, body2), arbiter);

                    arbiterCreated = true;
                }
            }

            Contact contact = null;

            if (arbiter.body1 == body1)
            {
                TSVector.Negate(ref normal, out normal);
                contact = arbiter.AddContact(point1, point2, normal, penetration, contactSettings);
            }
            else
            {
                contact = arbiter.AddContact(point2, point1, normal, penetration, contactSettings);
            }

            if (arbiterCreated)
            {
                if (anyBodyColliderOnly)
                {
                    /*if (body1.isColliderOnly) {
                     *  events.RaiseTriggerBeginCollide(body1, body2);
                     * } else {
                     *  events.RaiseTriggerBeginCollide(body2, body1);
                     * }*/

                    events.RaiseTriggerBeginCollide(contact);

                    body1.arbitersTrigger.Add(arbiter);
                    body2.arbitersTrigger.Add(arbiter);

                    OverlapPairContact overlapContact = new OverlapPairContact(body1, body2);
                    overlapContact.contact = contact;

                    initialTriggers.Add(overlapContact);
                }
                else
                {
                    events.RaiseBodiesBeginCollide(contact);
                    addedArbiterQueue.Enqueue(arbiter);

                    OverlapPairContact overlapContact = new OverlapPairContact(body1, body2);
                    overlapContact.contact = contact;

                    initialCollisions.Add(overlapContact);
                }
            }

            if (!anyBodyColliderOnly && contact != null)
            {
                events.RaiseContactCreated(contact);
            }
        }
Ejemplo n.º 22
0
		private void AddNode(HashList<FullCellAddr> sorted, FullCellAddr node) {
			HashSet<FullCellAddr> precedents;
			if (GetPrecedents(node, out precedents)) {
				Cell cell;
				foreach (FullCellAddr precedent in precedents) {
					// By including only non-input Formula and ArrayFormula cells, we avoid that 
					// constant cells get stored in local variables.  The result will not contain 
					// constants cells (and will contain an input cell only if it is also the 
					// output cell), so must the raw graph to find all cells belonging to an SDF.
					if (!sorted.Contains(precedent)
						&& precedent.TryGetCell(out cell)
						&& (cell is Formula || cell is ArrayFormula)
						&& !inputCellSet.Contains(precedent)) {
						AddNode(sorted, precedent);
					}
				}
			}
			sorted.Add(node); // Last in HashList
		}
        public void DefineGetAllInstancesMethod(TypeDefinition containerType, ModuleDefinition module,
                                                IDictionary <IDependency, IImplementation> serviceMap)
        {
            var targetMethods = new List <MethodDefinition>();

            foreach (MethodDefinition method in containerType.Methods)
            {
                if (method.Name != "GetAllInstances")
                {
                    continue;
                }

                targetMethods.Add(method);
            }

            var getAllInstancesMethod = targetMethods[0];

            // Remove the stub implementation
            var body = getAllInstancesMethod.Body;
            var IL   = body.GetILProcessor();

            body.InitLocals = true;
            body.Instructions.Clear();

            var listVariable = getAllInstancesMethod.AddLocal <List <object> >();
            var listCtor     = module.ImportConstructor <List <object> >();

            IL.Emit(OpCodes.Newobj, listCtor);
            IL.Emit(OpCodes.Stloc, listVariable);

            // Group the dependencies by type
            var dependenciesByType = new HashList <Type, IDependency>();

            foreach (var dependency in serviceMap.Keys)
            {
                var serviceType = dependency.ServiceType;
                dependenciesByType.Add(serviceType, dependency);
            }

            var getTypeFromHandleMethod = typeof(Type).GetMethod("GetTypeFromHandle", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
            var getTypeFromHandle       = module.Import(getTypeFromHandleMethod);
            var addItem = module.ImportMethod <List <object> >("Add");

            var currentService = getAllInstancesMethod.AddLocal <object>();

            foreach (var currentType in dependenciesByType.Keys)
            {
                var currentTypeRef = module.Import(currentType);

                var currentList = dependenciesByType[currentType];
                if (currentList.Count == 0)
                {
                    continue;
                }

                var skipAdd = IL.Create(OpCodes.Nop);
                IL.Emit(OpCodes.Ldarg_1);
                IL.Emit(OpCodes.Ldtoken, currentTypeRef);
                IL.Emit(OpCodes.Call, getTypeFromHandle);
                IL.Emit(OpCodes.Ceq);
                IL.Emit(OpCodes.Brfalse, skipAdd);

                foreach (var dependency in currentList)
                {
                    IL.Emit(OpCodes.Ldloc, listVariable);

                    var implementation = serviceMap[dependency];
                    implementation.Emit(dependency, serviceMap, getAllInstancesMethod);

                    IL.Emit(OpCodes.Stloc, currentService);

                    // Call IInitialize.Initialize(container) on the current service type
                    _initializer.Initialize(IL, module, currentService);

                    IL.Emit(OpCodes.Ldloc, currentService);
                    IL.Emit(OpCodes.Callvirt, addItem);
                }

                IL.Append(skipAdd);
            }

            var skipOtherContainerCall = IL.Create(OpCodes.Nop);

            var getNextContainer = module.ImportMethod <IMicroContainer>("get_NextContainer");
            var otherContainer   = getAllInstancesMethod.AddLocal <IMicroContainer>();

            // var otherContainer = this.NextContainer;
            IL.Emit(OpCodes.Ldarg_0);
            IL.Emit(OpCodes.Callvirt, getNextContainer);
            IL.Emit(OpCodes.Stloc, otherContainer);

            // if (otherContainer != null && this != otherContainer) {
            IL.Emit(OpCodes.Ldloc, otherContainer);
            IL.Emit(OpCodes.Brfalse, skipOtherContainerCall);

            IL.Emit(OpCodes.Ldloc, otherContainer);
            IL.Emit(OpCodes.Ldarg_0);
            IL.Emit(OpCodes.Ceq);
            IL.Emit(OpCodes.Brtrue, skipOtherContainerCall);

            // var otherInstances = NextContainer.GetAllInstances(type);
            var otherGetAllInstancesMethod = module.ImportMethod <IMicroContainer>("GetAllInstances");

            IL.Emit(OpCodes.Ldloc, listVariable);
            IL.Emit(OpCodes.Ldloc, otherContainer);
            IL.Emit(OpCodes.Ldarg_1);
            IL.Emit(OpCodes.Callvirt, otherGetAllInstancesMethod);

            // resultList.AddRange(otherInstances);
            var addRangeMethod = module.ImportMethod <List <object> >("AddRange");

            IL.Emit(OpCodes.Callvirt, addRangeMethod);

            // }

            // Cast the results down to an IEnumerable<object>
            var enumerableType = module.ImportType <IEnumerable <object> >();

            IL.Append(skipOtherContainerCall);
            IL.Emit(OpCodes.Ldloc, listVariable);
            IL.Emit(OpCodes.Isinst, enumerableType);
            IL.Emit(OpCodes.Ret);
        }
Ejemplo n.º 24
0
 public void AddDependencies(Bundle subBundle)
 {
     subBundle.Parent = this;
     Dependencies.Add(subBundle);
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Obtains a list of services (grouped by type) from the list of assemblies.
        /// </summary>
        /// <param name="assemblies">The list of assemblies that contain the types that will be injected into the dependency map.</param>
        /// <returns>A list of services grouped by type.</returns>
        private HashList<Type, IServiceInfo> GetServiceList(IEnumerable<Assembly> assemblies)
        {
            if (assemblies == null)
                throw new ArgumentNullException("assemblies");

            var serviceList = new HashList<Type, IServiceInfo>();
            foreach (var assembly in assemblies)
            {
                var services = _serviceLoader.Load(assembly);
                foreach (var service in services)
                {
                    var serviceType = service.ServiceType;

                    // Group the services by service type
                    serviceList.Add(serviceType, service);
                }
            }

            return serviceList;
        }
Ejemplo n.º 26
0
        /// <summary>
        /// type_method = [ "static" ], signature, method_name, [ ":", signature, identifier, { ",", signature, identifier } ], "{", { local_stmt }, "}" ;
        /// </summary>
        private void ParseTypeMethod()
        {
            // ? "static"
              bool isStatic = false;
              if (PeekLexem(LexemType.Static))
              {
            SkipLexem();
            isStatic = true;
              }

              // signature
              var methodType = ParseSignature();

              // <method_name>
              if (!PeekLexem(LexemType.Identifier)) Error(Resources.errMethodNameExpected);
              var methodName = GetLexem();
              if (ReservedMethods.ContainsKey(methodName.Data) && ReservedMethods[methodName.Data] != methodType.Signature)
            Error(String.Format(Resources.errSpecialIncorrectReturnType, methodName.Data, ReservedMethods[methodName.Data]));

              // validate static constructor
              if (methodName.Data == "construct" && isStatic)
            Error(String.Format(Resources.errStaticConstructor, Compiler.Emitter.CurrentType.Name));

              SkipLexem();

              HashList<ParameterNode> parameters = null;
              // ? "(", params, ")"
              if(PeekLexem(LexemType.ParenOpen))
              {
            SkipLexem();

            parameters = new HashList<ParameterNode>();
            var idx = 0;

            while(!PeekLexem(LexemType.ParenClose, LexemType.EOF))
            {
              // separator
              if(idx > 0)
              {
            if (!PeekLexem(LexemType.Comma)) Error(Resources.errCommaExpected);
            SkipLexem();
              }

              // signature
              var paramType = ParseSignature();
              // <name>
              if (!PeekLexem(LexemType.Identifier)) Error(Resources.errParameterNameExpected);
              var paramName = GetLexem();
              if (parameters.Contains(paramName.Data)) Error(String.Format(Resources.errParameterNameDuplicated, paramName.Data));
              parameters.Add(paramName.Data, new ParameterNode(paramName.Data, paramType, idx));
              SkipLexem();
              idx++;
            }

            // ")"
            if (!PeekLexem(LexemType.ParenClose))
              Error(Resources.errParenExpected);
            SkipLexem();
              }

              MethodNode method;
              if (methodName.Data == "construct")
            method = Compiler.Emitter.CreateCtor(Compiler.Emitter.CurrentType, parameters);
              else
            method = Compiler.Emitter.CreateMethod(Compiler.Emitter.CurrentType, methodName.Data, methodType, parameters, isStatic);

              method.Lexem = methodName;
              Compiler.Emitter.CurrentMethod = method;

              // lookahead "{"
              if (!PeekLexem(LexemType.CurlyOpen)) Error(Resources.errMethodCurlyBrace);

              method.Body = ParseCodeBlock();

              Compiler.Emitter.CurrentMethod = null;
        }
Ejemplo n.º 27
0
        public void Simple()
        {
            var hashList = new HashList <int, string> {
                { 2, "a" }
            };

            Assert.AreEqual(hashList.ValueCount, 1);
            Assert.AreEqual(hashList.KeyCount, 1);

            hashList.Add(4, new List <string>(new[] { "2", "3", "4", "5" }));

            Assert.AreEqual(hashList.ValueCount, 5);
            Assert.AreEqual(hashList.KeyCount, 2);

            Assert.IsTrue(hashList.Remove(2));
            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 4);

            Assert.IsFalse(hashList.Remove(2));
            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 4);

            Assert.IsTrue(hashList.RemoveValue("2"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            Assert.IsFalse(hashList.Remove(3, "2"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            Assert.IsFalse(hashList.Remove(4, "2"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            Assert.IsTrue(hashList.Remove(4, "5"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 2);

            hashList.Add(4, "4");

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);

            hashList.RemoveAll("4");

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 1);

            Assert.IsFalse(hashList.Remove(10));

            hashList.Add(4, "5");
            hashList.Add(4, "6");

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 3);


            Assert.IsTrue(hashList.RemoveValue("5"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 2);

            Assert.IsFalse(hashList.RemoveValue("5"));

            Assert.AreEqual(hashList.KeyCount, 1);
            Assert.AreEqual(hashList.ValueCount, 2);
        }