public void SetHashValue(int x, int y, int z, T value)
 {
     if (mapHashXY[x, y] == null)
     {
         mapHashXY[x, y] = new List <IndexAndValue <T> >();
         mapHashXY[x, y].Add(new IndexAndValue <T>(z, value));
         Count++;
     }
     else
     {
         if (mapHashXZ[x, z] == null)
         {
             mapHashXZ[x, z] = new List <IndexAndValue <T> >();
             mapHashXZ[x, z].Add(new IndexAndValue <T>(y, value));
             Count++;
         }
         else
         {
             if (mapHashYZ[y, z] == null)
             {
                 mapHashYZ[y, z] = new List <IndexAndValue <T> >();
                 mapHashYZ[y, z].Add(new IndexAndValue <T>(x, value));
                 Count++;
             }
             else
             {
                 List <IndexAndValue <T> > list = null;
                 IndexAndValue <T>         ele  = new IndexAndValue <T>(-1, value);
                 if (mapHashXY[x, y].Count < mapHashXZ[x, z].Count)
                 {
                     list      = mapHashXY[x, y];
                     ele.Index = z;
                 }
                 else
                 {
                     list      = mapHashXZ[x, z];
                     ele.Index = y;
                 }
                 if (mapHashYZ[y, z].Count < list.Count)
                 {
                     list      = mapHashYZ[y, z];
                     ele.Index = x;
                 }
                 list.Add(ele);
                 Count++;
             }
         }
     }
 }
Пример #2
0
        public WaveLogic(Direction direction, IBars bars, int barIndex, double eDistanceInPoints, double xDistanceInPoints)
        {
            _bars = bars;
            _barIndexOfPreviousTick = barIndex;
            _eDistanceInPoints      = eDistanceInPoints;
            _xDistanceInPoints      = xDistanceInPoints;
            Direction = direction;
            State     = WaveStates.FormedA;
            var currentHigh = bars.GetHigh(barIndex);
            var currentLow  = bars.GetLow(barIndex);

            A       = new IndexAndValue(barIndex, direction.IsUp ? currentHigh : currentLow);
            MaxLow  = double.MinValue;
            MinHigh = double.MaxValue;
        }
Пример #3
0
    private static IndexAndValue[] Initialize(int[] P, int B0, int X, int Y, int N)
    {
        var result = new IndexAndValue[N];

        for (int i = 0; i < result.Length; i++)
        {
            if (i < P.Length)
            {
                result[i] = new IndexAndValue(i, P[i]);
            }
            else if (i == P.Length)
            {
                result[i] = new IndexAndValue(i, B0);
            }
            else
            {
                result[i] = new IndexAndValue(i, (int)(((long)result[i - 1].Value * X + Y) % 1000000007));
            }
        }

        return(result);
    }