//-------------------------------------------------------------------------
        public virtual void test_noNulls_Map_ok()
        {
            ImmutableSortedMap <string, string> expected = ImmutableSortedMap.of("A", "B");
            ImmutableSortedMap <string, string> result   = ArgChecker.noNulls(expected, "name");

            assertEquals(result, expected);
        }
        //-------------------------------------------------------------------------
        public virtual void test_notEmpty_Map_ok()
        {
            SortedDictionary <string, string> expected = ImmutableSortedMap.of("Element", "Element");
            SortedDictionary <string, string> result   = ArgChecker.notEmpty(expected, "name");

            assertEquals(result, expected);
        }
        public virtual void test_toImmutableSortedMap_keyValue()
        {
            IList <string> list = Arrays.asList("bob", "a", "ab");
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            ImmutableSortedMap <int, string> test = list.collect(Guavate.toImmutableSortedMap(s => s.length(), s => "!" + s));

            assertEquals(test, ImmutableSortedMap.naturalOrder().put(1, "!a").put(2, "!ab").put(3, "!bob").build());
        }
        //-------------------------------------------------------------------------
        public virtual void test_toMap()
        {
            ImmutableSortedMap <Currency, double> test = MultiCurrencyAmount.of(CA1, CA2).toMap();

            assertEquals(test.size(), 2);
            assertEquals(test.containsKey(CA1.Currency), true);
            assertEquals(test.containsKey(CA2.Currency), true);
            assertEquals(test.get(CA1.Currency), Convert.ToDouble(CA1.Amount));
            assertEquals(test.get(CA2.Currency), Convert.ToDouble(CA2.Amount));
        }
Пример #5
0
 private static void Perf_Get(long count, ImmutableSortedMap <long, long> im)
 {
     using (Benchmark.Run("Get", count))
     {
         var sum = 0L;
         for (int i = 0; i < count; i++)
         {
             var x = im[i];
             sum += x;
         }
     }
 }
Пример #6
0
 private static void Perf_GetLoop(long count, ImmutableSortedMap <long, long> im)
 {
     using (Benchmark.Run("Get C# loop", count))
     {
         var sum = 0L;
         var c   = KeyComparer <long> .Default;
         for (int i = 0; i < count; i++)
         {
             var x = Find(c, i, im.Tree);
             sum += x;
         }
     }
 }
Пример #7
0
        // restricted constructor
        private EnumNames(Type <T> enumType, bool manualToString)
        {
            this.enumType = ArgChecker.notNull(enumType, "enumType");
            SortedDictionary <string, T> map          = new SortedDictionary <string, T>();
            SortedSet <string>           formattedSet = new SortedSet <string>();
            Dictionary <T, string>       formatMap    = new Dictionary <T, string>(enumType);

            foreach (T value in enumType.EnumConstants)
            {
                string formatted = manualToString ? value.ToString() : CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, value.name());
                map[value.name()] = value;
                map[value.name().ToUpper(Locale.ENGLISH)] = value;
                map[value.name().ToLower(Locale.ENGLISH)] = value;
                map[formatted] = value;
                map[formatted.ToUpper(Locale.ENGLISH)] = value;
                map[formatted.ToLower(Locale.ENGLISH)] = value;
                formattedSet.Add(formatted);
                formatMap[value] = formatted;
            }
            this.parseMap     = ImmutableSortedMap.copyOf(map);
            this.formattedSet = ImmutableSortedSet.copyOf(formattedSet);
            this.formatMap    = formatMap;
        }
Пример #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ImmutableConstructor private MultiCurrencyAmountArray(int size, java.util.Map<Currency, com.opengamma.strata.collect.array.DoubleArray> values)
        private MultiCurrencyAmountArray(int size, IDictionary <Currency, DoubleArray> values)
        {
            this.values       = ImmutableSortedMap.copyOf(values);
            this.size_Renamed = size;
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance of the raw volatility.
 /// <para>
 /// The data values can be model parameters (like Black or normal volatilities) or direct option prices.
 ///
 /// </para>
 /// </summary>
 /// <param name="data">  the map of data by tenor </param>
 /// <returns> the instance </returns>
 public static TenorRawOptionData of(IDictionary <Tenor, RawOptionData> data)
 {
     return(new TenorRawOptionData(ImmutableSortedMap.copyOf(data)));
 }
 private TenorRawOptionData(SortedDictionary <Tenor, RawOptionData> data)
 {
     JodaBeanUtils.notNull(data, "data");
     this.data = ImmutableSortedMap.copyOfSorted(data);
 }