Ejemplo n.º 1
0
        public void TryGetValue_Present()
        {
            var d = new DictionarySlim <char, int>();

            d.GetOrAddValueRef('a') = 9;
            d.GetOrAddValueRef('b') = 11;
            Assert.Equal(true, d.TryGetValue('a', out int value));
            Assert.Equal(9, value);
            Assert.Equal(true, d.TryGetValue('b', out value));
            Assert.Equal(11, value);
        }
Ejemplo n.º 2
0
        public bool TryCreateFormatter(Type type, out IFormatter formatter)
        {
            if (!Formatters.TryGetValue(type, out formatter))
            {
                formatter = DefaultObjectFormatter;
            }

            return(true);
        }
Ejemplo n.º 3
0
        public void TryGetValue_Missing()
        {
            var d = new DictionarySlim <char, int>();

            d.GetOrAddValueRef('a') = 9;
            d.GetOrAddValueRef('b') = 11;
            d.Remove('b');
            Assert.Equal(false, d.TryGetValue('z', out int value));
            Assert.Equal(default, value);
        private string WriteCount(DictionarySlim <long, int> dictionary, string fragment)
        {
            long key = 0;

            for (int i = 0; i < fragment.Length; ++i)
            {
                key = (key << 2) | tonum[fragment[i]];
            }
            dictionary.TryGetValue(key, out int v);
            return(string.Concat(v.ToString(), "\t", fragment));
        }
 private void Assemble3ByteInstruction(Match match) // assembles all 3 byte instructions
 {
     if (counter <= ushort.MaxValue - 2)
     {
         byte inst_value = Instructions[match.Groups["3"].Value];
         temp_memory[counter] = inst_value;
         counter++;
         byte[] address = new byte[2];
         if (match.Groups["hex3"].Success)
         {
             address = BitConverter.GetBytes(Convert.ToUInt16(match.Groups["hex3"].Value, 16));
         }
         else if (match.Groups["dec3"].Success)
         {
             address = BitConverter.GetBytes(Convert.ToUInt16(match.Groups["dec3"].Value));
         }
         else if (match.Groups["bin3"].Success)
         {
             address = BitConverter.GetBytes(Convert.ToUInt16(match.Groups["bin3"].Value, 2));
         }
         else if (match.Groups["lbl3"].Success)
         {
             if (labels.TryGetValue(match.Groups["lbl3"].Value, out ushort label_address))
             {
                 address = BitConverter.GetBytes(label_address);
             }
             else
             {
                 to_be_resolved.Add(match.Groups["lbl3"].Value, new KeyValuePair <ushort, int>(counter, line_number));
             }
         }
         temp_memory[counter] = address[0];
         counter++;
         temp_memory[counter] = address[1];
         counter++;
     }
     else
     {
         errors_list.Add(new AssembleError($"Not enough memory to add 3-byte instruction {match.Groups["2"].Value} to memory address {counter.ToString("X")}", line_number));
     }
 }
 public void DictionarySlimRead() => dictionarySlim.TryGetValue(value, out bool r);
Ejemplo n.º 7
0
 public string DictionarySlim_TryGetValue()
 {
     _dictSlim.TryGetValue(LookupKey, out var result);
     return(result);
 }