private List<PointF> DivideAndConquer(List<PointF> points)
        {
            if (points.Count == 2 || points.Count == 3)
            {
                // TODO make sure they are in CC order starting with the left-most
                return points;
            }

            // Find the middle index
            int middleIdx = points.Count / 2;
            if(points.Count % 2 == 1)
                middleIdx++;

            // DAC the left and right ranges of the points
            List<PointF> edgePtsLeft = DivideAndConquer(points.GetRange(0, middleIdx));
            List<PointF> edgePtsRight = DivideAndConquer(points.GetRange(middleIdx, points.Count - middleIdx));

            // Get upper and lower tangent indexes
            Tuple<int, int> upperTangentIndexes = FindUpperTangent();
            Tuple<int, int> lowerTangentIndexes = FindLowerTangent();
            int idxOfUpperTangentInEdgePtsL = upperTangentIndexes.Item1;
            int idxOfUpperTangentInEdgePtsR = upperTangentIndexes.Item2;
            int idxOfLowerTangentInEdgePtsL = lowerTangentIndexes.Item1;
            int idxOfLowerTangentInEdgePtsR = lowerTangentIndexes.Item2;

            // Combine the new hulls using the newly found indexes
            List<PointF> combinedEdgePts = new List<PointF>();
            return combinedEdgePts;
        }
Example #2
0
        private static void ReceiveUDP(IAsyncResult ar)
        {
            var u = (UdpClient)((UdpState)(ar.AsyncState)).u;
            var e = (IPEndPoint)((UdpState)(ar.AsyncState)).e;
            var rawBytes = new List<byte>();
            rawBytes.AddRange(u.EndReceive(ar, ref e));
            var FromAddress = rawBytes.GetRange(1, rawBytes[0]);

            var receiveBytes = rawBytes.GetRange(rawBytes[0] + 1, rawBytes.Count - 1 - rawBytes[0]).ToArray();

            switch ((PDUbase.MessageTypeIndicator)receiveBytes[0])
            {
                case PDUbase.MessageTypeIndicator.DeliverReport:
                case PDUbase.MessageTypeIndicator.Command:
                    break;
                case PDUbase.MessageTypeIndicator.Submit:
                    var packet = new SMS_Submit {BinaryForm = receiveBytes};
                    var hairpin = packet.DestinationAddress.ToString().StartsWith("21") ||
                                  packet.DestinationAddress.ToString().StartsWith("11");
                    if (hairpin)
                    {
                        UDP.SendSMS(packet.UserData.ToString(), packet.DestinationAddress.ToString(), FromAddress.ToString());
                        break;
                    }
                    Http.SendSMS(packet.UserData.ToString(), packet.DestinationAddress.ToString(), "");
                    break;
                default:
                    break;
            }
        }
Example #3
0
		public static DataSeriesInfo GetDataSeriesInfo(string seriesName)
		{
			DataSeriesInfo dataSeriesInfo = new DataSeriesInfo();
			dataSeriesInfo.SeriesName = seriesName;
			List<string> list = new List<string>((IEnumerable<string>)seriesName.Split(new char[] { '.' }));
			dataSeriesInfo.DataType = DataType.Unknown;
			switch (list[list.Count - 1])
			{
				case "Daily":
					dataSeriesInfo.DataType = DataType.Daily;
					break;
				case "Trade":
					dataSeriesInfo.DataType = DataType.Trade;
					break;
				case "Quote":
					dataSeriesInfo.DataType = DataType.Quote;
					break;
				case "Depth":
					dataSeriesInfo.DataType = DataType.MarketDepth;
					break;
			}
			int count = 1;
			long result;
			if (dataSeriesInfo.DataType == DataType.Unknown && list.Count >= 4 && (list[list.Count - 3] == "Bar" && Enum.IsDefined(typeof(BarType), (object)list[list.Count - 2])) && long.TryParse(list[list.Count - 1], out result))
			{
				dataSeriesInfo.DataType = DataType.Bar;
				dataSeriesInfo.BarType = (BarType)Enum.Parse(typeof(BarType), list[list.Count - 2]);
				dataSeriesInfo.BarSize = result;
				count = 3;
			}
			dataSeriesInfo.Symbol = string.Join('.'.ToString(), list.GetRange(0, list.Count - count).ToArray());
			dataSeriesInfo.Suffix = string.Join('.'.ToString(), list.GetRange(list.Count - count, count).ToArray());
			return dataSeriesInfo;
		}
Example #4
0
		/// <summary>
		/// Splits the shaders.
		/// </summary>
		/// <param name="shaderBuffer">The shader buffer.</param>
		private Shader SplitShaders(List<string> shaderBuffer,ref string name){
			int vertexShaderOffset=0, fragmentShaderOffset=0, lineCount=0;
			string version="";
			foreach (string line in shaderBuffer)
			{
				if (line.Contains("#pragma vertex")) {
					vertexShaderOffset = lineCount + 1;
				} else if (line.Contains("#pragma fragment")) {
					fragmentShaderOffset = lineCount + 1;
				} else if (line.Contains ("#version")) {
					version = line;
				}
				lineCount++;
			}

			List<string> vertexShaderBuffer = 
				shaderBuffer.GetRange(vertexShaderOffset, fragmentShaderOffset-vertexShaderOffset);
			vertexShaderBuffer.Insert (0, version);
			List<string> fragmentShaderBuffer = 
				shaderBuffer.GetRange(fragmentShaderOffset, lineCount-fragmentShaderOffset);
			fragmentShaderBuffer.Insert (0, version);

			string vertexShader, fragmentShader;
			ProcessIncludes(vertexShaderBuffer, out vertexShader);
			ProcessIncludes(fragmentShaderBuffer, out fragmentShader);

			return new Shader (ref vertexShader,ref fragmentShader,ref name);
		}
        /// <summary>
        /// Parses csv to TestCases
        /// </summary>
        /// <param name="data">data parameter</param>
        /// <param name="resources">resources parameter</param>
        /// <returns>TestCase list</returns>
        public static TestCases Parse(List<List<string>> data, ResourceManager resources = null)
        {
            if (data == null || !data.Any()) { throw new ArgumentNullException("data"); }

            var rootHeader = HeaderParser.Parse(data);
            HeaderValidator.Validate(rootHeader);

            var cases = new TestCases();
            var lastStartIndex = 0;

            for (var i = HeaderParser.HeaderRowCount; i < data.Count; i++)
            {
                var row = data[i];
                if (!string.IsNullOrWhiteSpace(row[0]))
                {
                    if (i != HeaderParser.HeaderRowCount)
                    {
                        cases.Add(TestCaseParser.Parse(rootHeader, data.GetRange(lastStartIndex, i - lastStartIndex), resources));
                    }

                    lastStartIndex = i;
                }
            }

            cases.Add(TestCaseParser.Parse(rootHeader, data.GetRange(lastStartIndex, data.Count - lastStartIndex), resources));

            return cases;
        }
        public override List<int> Sort(List<int> listToSort)
        {
            // Create a new deep copy of the list to avoid conflicts
            List<int> resultList = new List<int>(listToSort);

            // Trivial case
            if (resultList.Count <= 1)
            {
                return resultList;
            }

            // Determine middle index of the data set
            int middleIndex = resultList.Count / 2;

            // Split data into two vectors
            List<int> leftSubList = resultList.GetRange(0, middleIndex);
            List<int> rightSubList = resultList.GetRange(middleIndex, resultList.Count - middleIndex);

            // Recursive merge sort of the two vectors
            leftSubList = Sort(leftSubList);
            rightSubList = Sort(rightSubList);

            // Merge sorted reults
            return merge(leftSubList, rightSubList);
        }
Example #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ipds"></param>
        /// <param name="sampleSize"></param>
        /// <param name="windowSize"></param>
        public static List<decimal> Test(List<decimal> ipds, int sampleSize, int windowSize)
        {
            List<decimal> results = new List<decimal>();

            while (ipds.Count > 0)
            {
                List<decimal> sampleIpds;

                if (ipds.Count > sampleSize)
                {
                    sampleIpds = ipds.GetRange(0, sampleSize);
                    ipds.RemoveRange(0, sampleSize);
                }
                else
                {
                    sampleIpds = ipds.GetRange(0, ipds.Count);
                    ipds.Clear();
                }

                decimal result = CalculateRegularity(sampleIpds, windowSize);

                results.Add(result);
            }

            return results;
        }
Example #8
0
 private static List<Point> SimplifyLine(List<Point> points, double eps)
 {
     Line l = new Line(points[0], points[points.Count - 1]);
     double maxDist = 0;
     int maxIndex = 0;
     for (int i = 1; i < points.Count - 1; i++) {
         double dist = l.PointDistance(points[i]);
         if (dist > maxDist)
         {
             maxDist = dist;
             maxIndex = i;
         }
     }
     if (maxDist > eps)
     {
         List<Point> newPoints = new List<Point>();
         List<Point> list1 = points.GetRange(0, maxIndex);
         List<Point> list2 = points.GetRange(maxIndex, points.Count - maxIndex);
         list1 = SimplifyLine(list1, eps);
         list2 = SimplifyLine(list2, eps);
         newPoints.AddRange(list1);
         newPoints.RemoveAt(newPoints.Count - 1);
         newPoints.AddRange(list2);
         return newPoints;
     }
     else
     {
         List<Point> newPoints = new List<Point>();
         newPoints.Add(points[0]);
         newPoints.Add(points[points.Count - 1]);
         return newPoints;
     }
 }
        /// <summary>
        /// An estimated characteristic of occurrence of the subject word in the sequence
        /// </summary>
        /// <param name="accord">
        /// Checking word.
        /// </param>
        /// <param name="chainLength">
        /// Length of whole sequence.
        /// </param>
        /// <param name="winLen">
        /// Length of the scanning window.
        /// </param>
        /// <param name="minusOne">
        /// Data for "minus one" subword.
        /// </param>
        /// <param name="mid">
        /// Data for "minus two" subword.
        /// </param>
        /// <returns>
        /// Design characteristic of occurrence of the word.
        /// </returns>
        public double DesignExpected(List<string> accord, int chainLength, int winLen, DataCollector minusOne, DataCollector mid)
        {
            int shortWord = 2;
            int midlLength = winLen - 2;
            int minusLength = winLen - 1;

            List<int> left = minusOne.Positions(accord.GetRange(0, accord.Count - 1));
            List<int> right = minusOne.Positions(accord.GetRange(1, accord.Count - 1));
            List<int> middle = midlLength != 0 ? mid.Positions(accord.GetRange(1, accord.Count - 2)) : new List<int>();

            double criteria = -1;
            if (winLen == shortWord)
            {
                criteria = Frequency(left, chainLength, minusLength)
                           * Frequency(right, chainLength, minusLength);
            }
            else if (middle != null)
            {
                criteria = (Frequency(left, chainLength, minusLength)
                            * Frequency(right, chainLength, minusLength))
                           / Frequency(middle, chainLength, midlLength);
            }

            return criteria;
        }
Example #10
0
        public static void RealAllAsync(List<FilePathInfo> pathList)
        {
            int needThreadCount = 1;
            if (needThreadCount > 1)
            {
                int piece = pathList.Count / needThreadCount;
                for (int i = 0; i < needThreadCount - 1; i++)
                {
                    new ReadFileThread(pathList.GetRange(i * piece, piece));
                }
                new ReadFileThread(pathList.GetRange((needThreadCount - 1) * piece, pathList.Count - (needThreadCount - 1) * piece));
            }
            else
            {
                new ReadFileThread(pathList);
            }

            while (true)
            {
                Thread.Sleep(1000);
                if (finThreadCount == needThreadCount)
                {
                    break;
                }
            }
        }
Example #11
0
        /// <summary>
        /// 比较两个结果文件CnpA、CnpB,并将比较结果存到第一个文件所在的目录下
        /// CnpAAndCnpB.Cnp,CnpAOrCnpB.Cnp,CnpANotCnpB.Cnp,CnpBNotCnpA.Cnp
        /// return value: hashtable, values list as follows
        ///  key:"lst1AndLst2", value:CnpAAndCnpB中的结果数 
        ///  key:"lst1OrLst2", value:CnpAOrCnpB中的结果数   totalNum
        ///  key:"lst1NotLst2", value:CnpANotCnpB中的结果数 addNum
        ///  key:"lst2NotLst1", value:CnpBNotCnpA中的结果数 deleteNum
        /// </summary>
        public Hashtable Compare(String filePath1, byte[] file)
        {
            List<int> lst1 = GetResultList(filePath1);
            List<int> lst2 = new List<int>();

            List<int> lst1AndLst2 = new List<int>();
            List<int> lst1OrLst2 = new List<int>();
            List<int> lst1NotLst2 = new List<int>();
            List<int> lst2NotLst1 = new List<int>();

            int lstLength1 = lst1.Count;
            int lstLength2 = lst2.Count;
            int i = 0; // lst1的指针
            int j = 0; // lst2的指针
            for (; i < lstLength1 && j < lstLength2; )
            {
                if (lst1[i] == lst2[j])
                {
                    lst1AndLst2.Add(lst1[i]);
                    lst1OrLst2.Add(lst1[i]);
                    i++;
                    j++;
                }
                else if (lst1[i] > lst2[j])
                {
                    lst2NotLst1.Add(lst2[j]);
                    lst1OrLst2.Add(lst2[j]);
                    j++;
                }
                else if (lst1[i] < lst2[j])
                {
                    lst1NotLst2.Add(lst1[i]);
                    lst1OrLst2.Add(lst1[i]);
                    i++;
                }
            }

            // 将lst2的剩下的内容存入list
            if (lstLength1 == i)
            {
                lst2NotLst1.AddRange(lst2.GetRange(j, lstLength2 - j));
                lst1OrLst2.AddRange(lst2.GetRange(j, lstLength2 - j));
            }
            // 将lst1的剩下的内容存入list
            else if (lstLength2 == j)
            {
                lst1NotLst2.AddRange(lst1.GetRange(i, lstLength1 - i));
                lst1OrLst2.AddRange(lst1.GetRange(i, lstLength1 - i));
            }

            Hashtable resultNum = new Hashtable();
            //resultNum.Add("lst1AndLst2", lst1AndLst2.Count);
            //resultNum.Add("lst1OrLst2", lst1OrLst2.Count);
            //resultNum.Add("lst1NotLst2", lst1NotLst2.Count);
            //resultNum.Add("lst2NotLst1", lst2NotLst1.Count);
            lst1OrLst2.AddRange(lst2NotLst1);
            resultNum.Add("Num", lst1NotLst2.Count);
            resultNum.Add("File", lst1NotLst2.ToArray());
            return resultNum;
        }
	//Public entry function. All evaluations start here. If the expression is empty, return zero.
	//If the new operand is the start of a bracketed term, continue evaluating with an accumulator to collect the terms inside the brackets.
	//Otherwise, peel off the first number and continue evaluating.
	public static float evaluate(List<object> expression){
		if(expression.Count==0)
			return 0.0f;
		else if(expression[0].GetType()==typeof(OpenBracket))
			return evaluate (new List<object>(), expression.GetRange(1, expression.Count-1));
		return evaluate ((float)expression[0], expression.GetRange(1, expression.Count-1));
	}
Example #13
0
        //  Player list is needed in OnPlayerList, OnPlayerLeave and server.onRoundOverPlayers
        public new static List<CPlayerInfo> GetPlayerList(List<string> words) {
            List<CPlayerInfo> lstReturnList = new List<CPlayerInfo>();

            int currentOffset = 0;
            int parameterCount = 0;
            int playerCount = 0;

            if (words.Count > currentOffset && int.TryParse(words[currentOffset++], out playerCount) == true) {

                if (words.Count > 0 && int.TryParse(words[currentOffset++], out parameterCount) == true) {
                    List<string> lstParameters = words.GetRange(currentOffset, parameterCount);

                    currentOffset += parameterCount;

                    for (int i = 0; i < playerCount; i++) {
                        if (words.Count > currentOffset + (i * parameterCount)) {
                            lstReturnList.Add(new CPlayerInfo(lstParameters, words.GetRange(currentOffset + i * parameterCount, parameterCount)));
                        }
                    }

                }

            }

            return lstReturnList;
        }
Example #14
0
 //autocorr
 public static double computeAutocorr(List<double> values)
 {
     if (values.Count < 3) return 0;
     List<double> originList = values.GetRange(0, values.Count - 1),
                  shiftedList = values.GetRange(1, values.Count - 1);
     return Statistics.Covariance(originList, shiftedList) / (Statistics.StandardDeviation(originList) * Statistics.StandardDeviation(shiftedList));
 }
Example #15
0
 static List<int> MergeSort(List<int> list)
 {
     if (list.Count < 2)
         return list;//прекъсване на рекурсията, няма нужда да се сортира 1 елемент - връщаме list непроменен
     List<int> left = MergeSort( list.GetRange( 0, list.Count/2 ) );//сортирам лявата половина на списъка
     List<int> right = MergeSort( list.GetRange( left.Count, list.Count - left.Count ) );//сортирам дясната половина на списъка
     List<int> result = new List<int>();
     //left и right са сортирани, обединявам двата списъка в result:
     while (left.Count > 0 && right.Count > 0)//докато някой от двата списъка не се изпразни...
     {
         //...сравнявам първите елементи от двата списъка, премествам по-малкия в result
         if (left[0]<=right[0])
         {
             result.Add(left[0]);
             left.RemoveAt(0);
         }
         else
         {
             result.Add(right[0]);
             right.RemoveAt(0);
         }
     }
     //ако някой от двата списъка все още не е празен (поне 1 от тях е празен) - добавям го в result
     result.AddRange(left);
     result.AddRange(right);
     return result;
 }
Example #16
0
        public static void Purge() {
            // Keep only a certain number of each type of backup
            string logsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Constants.APPDATA_FOLDER, Constants.LOG_FOLDER);
            // If there's no folder, there probably aren't any logs
            if (!Directory.Exists(logsPath))
                return;
            string[] files = Directory.GetFiles(logsPath, "*.log");
            Array.Sort(files);

            string currentBackup = null;
            string backup;
            List<string> logsForBackup = new List<string>();

            foreach (string file in files) {
                backup = Path.GetFileNameWithoutExtension(file);
                backup = backup.Remove(backup.LastIndexOf('-'));
                if (backup != currentBackup) {
                    // Delete all but the last n files currently in the list
                    if (logsForBackup.Count > Constants.LOGS_KEEP_NUM) {
                        foreach (string fileToDelete in logsForBackup.GetRange(0, logsForBackup.Count - Constants.LOGS_KEEP_NUM)) {
                            File.Delete(fileToDelete);
                        }
                    }
                    logsForBackup.Clear();
                    currentBackup = backup;
                }
                logsForBackup.Add(file);
            }
            // And the final lot
            if (logsForBackup.Count > Constants.LOGS_KEEP_NUM) {
                foreach (string fileToDelete in logsForBackup.GetRange(0, logsForBackup.Count - Constants.LOGS_KEEP_NUM)) {
                    File.Delete(fileToDelete);
                }
            }
        }
        // Get a part of a parsed phrase-- drop parents when possible, create a new surrounding group when needed
        // start can be negative: count from end
        // count can be negative: use that many less than all the elements
        public static IParsedPhrase GetSubphrase(IParsedPhrase phrase, int start, int count)
        {
            IEnumerable<IParsedPhrase> branches = phrase.Branches;

            List<IParsedPhrase> included = new List<IParsedPhrase>();

            int ii = 0;
            foreach (IParsedPhrase branch in branches)
                if (ii++ >= start)
                    included.Add(branch);

            // start can be negative: count from end
            if (start < 0)
                included = included.GetRange(included.Count + start, -start);
            if (count > 0)
                included = included.GetRange(0, count);
            // count can be negative: less than max elts
            if (count < 0)
                included = included.GetRange(0, included.Count + count);

            if (included.Count == 0)
                return null;    // count <= start!
            if (included.Count == 1)
                return included[0];

            return new GroupPhrase(phrase.Part, included);
        }
	//Return the float if the expression has been completely evaluated. Otherwise continue evaluating based on the next operator
	private static float evaluate(float f, List<object> tail){
		if(tail.Count==0)
			return f;
		if(tail[0].GetType().IsSubclassOf(typeof(ProportionalOp)))
			return evaluate(f, (ProportionalOp)tail[0], tail.GetRange(1, tail.Count-1));
		else 																				//we still expect an operator, so it must be an incremental
			return evaluate(f, (IncrementalOp)tail[0], tail.GetRange(1, tail.Count-1));
	}
	//If the end of an expression has been reached reolve the current addition/subtraction and return the result.
	//If not resolve the current addition and subtraction if the next operation is of equal precedence.
	//Otherwise continue evaluating.
	private static float evaluate(float f1, IncrementalOp op, float f2, List<object> tail){
		if(tail.Count==0)
			return MathResolver.resolve((MathOp)op, f1, f2);
		else if(tail[0].GetType().IsSubclassOf(typeof(ProportionalOp)))
			return evaluate(f1, op, f2, (ProportionalOp)tail[0], tail.GetRange(1, tail.Count-1));
		else  																						//we still expect an operator, so it must be an incremental
			return evaluate(MathResolver.resolve((MathOp)op, f1, f2), (IncrementalOp)tail[0], tail.GetRange(1, tail.Count-1));
	}
 public override void ParseData(List<byte> bytes)
 {
     if (bytes.Count >= 48)
     {
         _data.SetBytes(bytes.GetRange(0, 36));
         _rateLimit.SetBytes(bytes.GetRange(36, 12));
     }
 }
Example #21
0
        public static List<float> BinaryFilter(List<float> list, CompareMethod compareMethod, float value)
        {
            int direction = (compareMethod == CompareMethod.smallerThan) ? -1 : 1;
            int middleIndex = 0, offset = 0;
            bool done = false;

            int firstIndex = 0;
            int lastIndex = list.Count - 1;

            while (!done)
            {
                middleIndex = GetMiddleIndex(firstIndex, lastIndex);
                float indexVal = list[middleIndex];
                if (indexVal == value)
                {
                    done = true;
                }
                else if (indexVal > value)
                {
                    if (lastIndex - firstIndex <= 1)
                    {
                        done = true;
                        offset = 1;
                    }
                    else
                    {
                        lastIndex = middleIndex;
                    }
                }
                else if (indexVal < value)
                {
                    if (lastIndex - firstIndex <= 1)
                    {
                        done = true;
                        offset = -1;
                    }
                    else
                    {
                        firstIndex = middleIndex;
                    }
                }
            }

            if (direction == -1 && (offset <= 0))
                return list.GetRange(0, middleIndex + 1);

            else if (direction == 1 && (offset >= 0))
                return list.GetRange(middleIndex, list.Count - middleIndex);

            else if (direction == 1 && offset == -1)
                return list.GetRange(middleIndex + 1, list.Count - (middleIndex + 1));

            else if (direction == -1 && offset == 1)
                return list.GetRange(0, middleIndex);

            return null;
        }
Example #22
0
        public static void TestUseCase()
        {
            var list = new List<int>(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });

            Assert.AreDeepEqual(list.GetRange(0, 2).ToArray(), new[] { 1, 2 }, "Bridge532 (0, 2)");
            Assert.AreDeepEqual(list.GetRange(1, 2).ToArray(), new[] { 2, 3 }, "Bridge532 (1, 2)");
            Assert.AreDeepEqual(list.GetRange(6, 3).ToArray(), new[] { 7, 8, 9 }, "Bridge532 (6, 3)");

        }
 internal ParamsFunctionReader(int numArgs, List<ValueReader> args, Type ret, 
     Func<ValueReader[], ValueReader[], object> function)
     : base(args, ret)
 {
     Args = args.GetRange(0, numArgs).ToArray();
     Params = args.GetRange(numArgs, args.Count - numArgs).ToArray();
     Function = function;
     ParamCopy = new ValueReader[Params.Length];
 }
Example #24
0
 public void SetBytes(List<byte> bytes)
 {
     if (bytes.Count >= 29)
     {
         _position.SetBytes(bytes.GetRange(0, 12));
         _attitude.SetBytes(bytes.GetRange(12, 16));
         _ccw = BitConverter.ToBoolean(bytes.ToArray(), 28);
     }
 }
        static void Main()
        {

            #region CREATE TEST OBJ
            //discipline
            List<Disciplines> disciplines = new List<Disciplines>();
            disciplines.Add(new Disciplines("Chemistry", 4, 6));
            disciplines.Add(new Disciplines("Math", 10, 10));
            disciplines.Add (new Disciplines("Biology", 8, 6));
            disciplines.Add(new Disciplines("Insurance", 10, 6));
            disciplines.Add(new Disciplines("Informatics", 10, 16));

            //teachers

            List<Teacher> teachers = new List<Teacher>();
            teachers.Add(new Teacher("Manolov",disciplines.GetRange(3,1)));
            teachers.Add(new Teacher("Minkov",disciplines.GetRange(0,2)));
            teachers.Add(new Teacher("Marinov", disciplines.GetRange(2, 1)));
            teachers.Add(new Teacher("Ovcharov", disciplines.GetRange(0, 3)));
            
                         
            //students
            List<Student> students = new List<Student>();
            students.Add(new Student("Martin", 3));
            students.Add(new Student("Darin", 13));
            students.Add(new Student("Rumqna", 6));
            students.Add(new Student("Emil", 33));
            students.Add(new Student("Nikola", 7));
            students.Add(new Student("Georgi", 1));
            
            //SchoolClasses
            List<SchoolClass> schoolClasses = new List<SchoolClass>();
            schoolClasses.Add(new SchoolClass(teachers, students, "3133"));            
           
            //school
            School school = new School("School Akademy",schoolClasses);   
            #endregion

            //-----TEST SCHOOL-------
            Console.WriteLine(school);

            #region TEST OPTIONAL COMMENTS
            Student vasko = new Student("Vasko",3);
            vasko.FreeComments = "OPTIONAL COMMENT TEST";
            vasko.ShowFreeComments();

            Teacher ra = new Teacher("Vasko", disciplines);
            ra.FreeComments = "OPTIONAL COMMENT TEST";
            ra.ShowFreeComments();

            SchoolClass da = new SchoolClass(teachers,students,"31231");
            da.FreeComments = "OPTIONAL COMMENT TEST";
            da.ShowFreeComments();
            #endregion

        }
Example #26
0
 public void SetBytes(List<byte> bytes)
 {
     if (bytes.Count >= 40)
     {
         Accelerometer.SetBytes(bytes.GetRange(0, 12));
         Gyro.SetBytes(bytes.GetRange(12, 12));
         Magnometer.SetBytes(bytes.GetRange(24, 12));
         _pressure = BitConverter.ToInt32(bytes.ToArray(), 36);
     }
 }
 void Divide(List<Vector3> toDivide, List<List<Vector3>> subsets)
 {
     if (toDivide.Count <= 3) {
         subsets.Add (toDivide);
     } else {
         int middleIndex = toDivide.Count / 2;
         Divide (toDivide.GetRange (0, middleIndex), subsets);
         Divide (toDivide.GetRange (middleIndex, toDivide.Count - middleIndex), subsets);
     }
 }
Example #28
0
        //Interquartile range
        public static double computeIQR(List<double> values)
        {
            //var median = Statistics.Median()
            values.Sort();
            int chunkLength = (int) values.Count / 2;
            List<double> firstHalf = values.GetRange(0, chunkLength)
                       , secondHalf = values.GetRange(values.Count() - chunkLength, chunkLength);

            return Statistics.Median(secondHalf) - Statistics.Median(firstHalf);
        }
Example #29
0
        static void Main(string[] args)
        {
            List<String> files = new List<String>();
            files.AddRange(Directory.GetFiles(diretorioOrigem));

            Thread thread1 = new Thread(() => { Move(files.GetRange(0, 5)); });
            thread1.Name = "thread1";
            thread1.Start();

            Thread thread2 = new Thread(() => { Move(files.GetRange(5, 5)); });
            thread2.Name = "thread2";
            thread2.Start();
        }
Example #30
0
        static List<Point> RecursiveSimplify(List<Point> points, 
		                                     double tolerance, 
		                                     bool isPolygon, 
		                                     bool isTopLevel)
        {
            double maxOrthoDistance = 0;
            int index = 0;

            for (int ii = 1; ii < points.Count - 1; ii++)
            {
                double orthoDistance = points[ii].Distance(points[points.Count-1], points[0]);

                if (orthoDistance > maxOrthoDistance)
                {
                    maxOrthoDistance = orthoDistance;
                    index = ii;
                }
            }

            if (maxOrthoDistance >= tolerance)
            {
                List<Point> pts1 = RecursiveSimplify(points.GetRange(0, index),
                                                     tolerance,
                                                     isPolygon,
                                                     false);
                List<Point> pts2 = RecursiveSimplify(points.GetRange(index, points.Count-index),
                                                     tolerance,
                                                     isPolygon,
                                                     false);

                pts1.RemoveAt(pts1.Count-1);
                pts1.AddRange(pts2);

                return pts1;
            }
            else
            {
                List<Point> result = new List<Point>();
                result.Add(points[0]);

                if (isTopLevel && isPolygon)
                {
                    result.Add(points[index]);
                }

                result.Add(points[points.Count-1]);

                return result;
            }
        }