public int IndexOf(SV s) { int index = -1; for (int i = 0; i < n; i++) { if (listSV[i] == s) { index = i; break; } } return(index); }
public void Insert(SV sv, int index) { SV[] listSVTemp = new SV[n + 1]; for (int i = 0; i < index; i++) { listSVTemp[i] = listSV[i]; } listSVTemp[index] = sv; for (int i = index + 1; i < n + 1; i++) { listSVTemp[i] = listSV[i - 1]; } listSV = listSVTemp; }
public void Sort() { for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (listSV[i].MSSV < listSV[j].MSSV) { SV temp = listSV[i]; listSV[i] = listSV[j]; listSV[j] = temp; } } } }
public void Add(SV s) { if (listSV == null || n == 0) { n = 1; listSV = new SV[1]; listSV[0] = s; } else { SV[] listSVTemp = new SV[n + 1]; for (int i = 0; i < n; i++) { listSVTemp[i] = listSV[i]; } listSVTemp[n] = s; n += 1; listSV = listSVTemp; } }
public void RemoveAt(int index) { if (0 <= index && index <= n - 1) { SV[] temp = new SV[n - 1]; for (int i = 0; i < index; i++) { temp[i] = listSV[i]; } for (int i = index + 1; i < n; i++) { temp[i - 1] = listSV[i]; } listSV = temp; n -= 1; } else { Console.WriteLine("No index {0}.\nIndex must be in {1} -> {2}!\n", index, 0, n - 1); } }