sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi.address/src/com/nokia/carbide/cpp/pi/address/GppTableSorter.java
changeset 2 b9ab3b238396
child 5 844b047e260d
equal deleted inserted replaced
1:1050670c6980 2:b9ab3b238396
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: 
       
    15  *
       
    16  */
       
    17 
       
    18 /*
       
    19  * GppTableSorter.java
       
    20  */
       
    21 package com.nokia.carbide.cpp.pi.address;
       
    22 
       
    23 import java.util.Enumeration;
       
    24 import java.util.Hashtable;
       
    25 import java.util.Vector;
       
    26 
       
    27 import com.nokia.carbide.cpp.internal.pi.model.ProfiledFunction;
       
    28 import com.nokia.carbide.cpp.internal.pi.model.ProfiledGeneric;
       
    29 import com.nokia.carbide.cpp.internal.pi.model.ProfiledThread;
       
    30 
       
    31 
       
    32 public class GppTableSorter
       
    33 {
       
    34 	private Vector<ProfiledGeneric> sortedList = null;
       
    35 //	private int columnID;
       
    36 	private int graphIndex;
       
    37 	private boolean sortAscending;
       
    38 	
       
    39 	public void setupSort(int columnID, int graphIndex, boolean sortAscending)
       
    40 	{
       
    41 //		this.columnID      = columnID;
       
    42 		this.graphIndex    = graphIndex;
       
    43 		this.sortAscending = sortAscending;
       
    44 	}
       
    45 
       
    46     public boolean isSortedByLoad(Vector<ProfiledGeneric> v)
       
    47 	{
       
    48     	//	  check if ProfiledGeneric vector is already sorted by load
       
    49 	  	int i = 0;
       
    50 		ProfiledGeneric tmp1 = null;
       
    51 		ProfiledGeneric tmp2 = null;
       
    52 		for (Enumeration e = v.elements(); e.hasMoreElements() ;i++)
       
    53 		{
       
    54 			tmp2 = (ProfiledGeneric)e.nextElement();
       
    55 			if (tmp1 != null)
       
    56 			{
       
    57 	      		float first  = tmp1.getPercentLoad(graphIndex);
       
    58 	      		float second = tmp2.getPercentLoad(graphIndex);
       
    59 
       
    60 	      		if ((first != second) && ((first < second) ^ sortAscending))
       
    61 				{
       
    62 					return false;
       
    63 				}
       
    64 			}
       
    65 			tmp1 = (ProfiledGeneric)v.elementAt(i);
       
    66 		}
       
    67 		return true;
       
    68 	}
       
    69 
       
    70 	public void quickSortByShow(Vector<ProfiledGeneric> elements)
       
    71 	{
       
    72 		Vector<ProfiledGeneric> v = elements;
       
    73 
       
    74 	  	if (!v.isEmpty())
       
    75 	    {
       
    76 	  		this.quickSortByShow(v, 0, v.size()-1);
       
    77 	    }
       
    78 
       
    79 	  	sortedList = v;
       
    80 	}
       
    81 
       
    82 	public void quickSortByAverageLoad(Vector<ProfiledGeneric> elements)
       
    83 	{
       
    84 	  	Vector<ProfiledGeneric> v = elements;
       
    85 
       
    86 	  	if (!v.isEmpty() & !isSortedByLoad(v))
       
    87 	    {
       
    88 	  		this.quickSortByAverageLoad(v, 0, v.size()-1);
       
    89 	    }
       
    90 
       
    91 	  	sortedList = v;
       
    92 	}
       
    93 
       
    94 	public void quickSortByName(Vector<ProfiledGeneric> elements, boolean caseSensitive)
       
    95 	{
       
    96 		Vector<ProfiledGeneric> v = elements;
       
    97 	  	if (!v.isEmpty())
       
    98 	    {
       
    99 	  		this.quickSortByName(v, 0, v.size()-1, caseSensitive);
       
   100 	    }
       
   101 
       
   102 	  	sortedList = v;
       
   103 	}
       
   104 
       
   105 	public void quickSortByThread(Vector<ProfiledGeneric> elements)
       
   106 	{
       
   107 		quickSortByName(elements, false);
       
   108 	}
       
   109 
       
   110 	public void quickSortByFunction(Vector<ProfiledGeneric> elements)
       
   111 	{
       
   112 		quickSortByName(elements, false);
       
   113 	}
       
   114 
       
   115 	public void quickSortByBinary(Vector<ProfiledGeneric> elements)
       
   116 	{
       
   117 		Vector<ProfiledGeneric> v = elements;
       
   118 
       
   119 	  	if (!v.isEmpty())
       
   120 	    {
       
   121 	  		this.quickSortByBinary(v, 0, v.size()-1);
       
   122 	    }
       
   123 
       
   124 	  	sortedList = v;
       
   125 	}
       
   126 
       
   127 	public void quickSortByBinaryPath(Vector<ProfiledGeneric> elements)
       
   128 	{
       
   129 		Vector<ProfiledGeneric> v = elements;
       
   130 
       
   131 	  	if (!v.isEmpty())
       
   132 	    {
       
   133 	  		this.quickSortByBinaryPath(v, 0, v.size()-1);
       
   134 	    }
       
   135 
       
   136 	  	sortedList = v;
       
   137 	}
       
   138 
       
   139 	public void quickSortByFullBinaryPath(Vector<ProfiledGeneric> elements)
       
   140 	{
       
   141 		Vector<ProfiledGeneric> v = elements;
       
   142 
       
   143 	  	if (!v.isEmpty())
       
   144 	    {
       
   145 	  		this.quickSortByFullBinaryPath(v, 0, v.size()-1);
       
   146 	    }
       
   147 
       
   148 	  	sortedList = v;
       
   149 	}
       
   150 
       
   151 	public void quickSortByStartAddress(Vector<ProfiledGeneric> elements)
       
   152 	{
       
   153 		Vector<ProfiledGeneric> v = elements;
       
   154 
       
   155 	  	if (!v.isEmpty())
       
   156 	    {
       
   157 	  		this.quickSortByStartAddress(v, 0, v.size()-1);
       
   158 	    }
       
   159 
       
   160 	  	sortedList = v;
       
   161 	}
       
   162 
       
   163 	public void quickSortByAssocBinary(Vector<ProfiledGeneric> elements)
       
   164 	{
       
   165 		Vector<ProfiledGeneric> v = elements;
       
   166 
       
   167 	  	if (!v.isEmpty())
       
   168 	    {
       
   169 	  		this.quickSortByAssocBinary(v, 0, v.size()-1);
       
   170 	    }
       
   171 
       
   172 	  	sortedList = v;
       
   173 	}
       
   174 
       
   175 	public void quickSortByAssocBinaryPath(Vector<ProfiledGeneric> elements)
       
   176 	{
       
   177 		Vector<ProfiledGeneric> v = elements;
       
   178 
       
   179 	  	if (!v.isEmpty())
       
   180 	    {
       
   181 	  		this.quickSortByAssocBinaryPath(v, 0, v.size()-1);
       
   182 	    }
       
   183 
       
   184 	  	sortedList = v;
       
   185 	}
       
   186 
       
   187 	public void quickSortByFullAssocBinaryPath(Vector<ProfiledGeneric> elements)
       
   188 	{
       
   189 		Vector<ProfiledGeneric> v = elements;
       
   190 
       
   191 	  	if (!v.isEmpty())
       
   192 	    {
       
   193 	  		this.quickSortByFullAssocBinaryPath(v, 0, v.size()-1);
       
   194 	    }
       
   195 
       
   196 	  	sortedList = v;
       
   197 	}
       
   198 
       
   199 	public void quickSortBySampleCount(Vector<ProfiledGeneric> elements)
       
   200 	{
       
   201 	  	Vector<ProfiledGeneric> v = elements;
       
   202 
       
   203 	  	if (!v.isEmpty())
       
   204 	    {
       
   205 	  		this.quickSortBySampleCount(v, 0, v.size()-1);
       
   206 	    }
       
   207 
       
   208 	  	sortedList = v;
       
   209 	}
       
   210 
       
   211 	public void quickSortByPriority(Vector<ProfiledGeneric> elements, Hashtable priorities)
       
   212 	{
       
   213 	    sortedList = new Vector<ProfiledGeneric>();
       
   214 	    Vector<ProfiledGeneric> v = elements;
       
   215 	  	int i = 0;
       
   216 		ProfiledThread tmp1 = null;
       
   217 		ProfiledThread tmp2 = null;
       
   218 		for (Enumeration e = v.elements(); e.hasMoreElements() ;i++)
       
   219 		{
       
   220 			tmp2 = (ProfiledThread)e.nextElement();
       
   221 			if (tmp1 != null)
       
   222 			{
       
   223 				Integer p1 = (Integer)priorities.get(new Integer(tmp1.getThreadId()));
       
   224 				Integer p2 = (Integer)priorities.get(new Integer(tmp2.getThreadId()));
       
   225 				p1 = (p1 == null) ? new Integer(Integer.MIN_VALUE) : p1;
       
   226 				p2 = (p2 == null) ? new Integer(Integer.MIN_VALUE) : p2;
       
   227 
       
   228 				if ((p1.compareTo(p2) != 0) && (p1.compareTo(p2) < 0) ^ sortAscending)
       
   229 				{
       
   230 					quickSortByPriority(v, 0, v.size()-1, priorities);
       
   231 
       
   232 					sortedList = v;
       
   233 					return;
       
   234 				}
       
   235 			}
       
   236 			tmp1 = (ProfiledThread)v.elementAt(i);
       
   237 		}
       
   238 		sortedList = v;
       
   239 		return;
       
   240 	}
       
   241 
       
   242 	private void quickSortByShow(Vector<ProfiledGeneric> elements, int lowIndex, int highIndex)
       
   243 	{
       
   244 		int lowToHighIndex;
       
   245 	    int highToLowIndex;
       
   246 	    int pivotIndex;
       
   247 	    ProfiledGeneric pivotValue;  // change the values to suit your application
       
   248 	    ProfiledGeneric lowToHighValue;
       
   249 	    ProfiledGeneric highToLowValue;
       
   250 	    ProfiledGeneric parking;
       
   251 	    int newLowIndex;
       
   252 	    int newHighIndex;
       
   253 
       
   254 	    lowToHighIndex = lowIndex;
       
   255 	    highToLowIndex = highIndex;
       
   256 
       
   257 	    pivotIndex = (lowToHighIndex + highToLowIndex) / 2;
       
   258 	    pivotValue = (ProfiledGeneric)elements.elementAt(pivotIndex);
       
   259 
       
   260 	    newLowIndex = highIndex + 1;
       
   261 	    newHighIndex = lowIndex - 1;
       
   262 	    while ((newHighIndex + 1) < newLowIndex)
       
   263 	    {
       
   264 			lowToHighValue = (ProfiledGeneric)elements.elementAt(lowToHighIndex);
       
   265 			while (lowToHighIndex < newLowIndex)
       
   266 			{
       
   267 				// chose false is less than true
       
   268 				// when sortAscending is true, sort from false to true
       
   269 	      		boolean first  = lowToHighValue.isEnabled(graphIndex);
       
   270 	      		boolean second = pivotValue.isEnabled(graphIndex);
       
   271 
       
   272 	      		if ((first == second) || ((!first && second) ^ sortAscending))
       
   273 	      			break;
       
   274 
       
   275 				newHighIndex = lowToHighIndex;
       
   276 			    lowToHighIndex ++;
       
   277 			    lowToHighValue = (ProfiledGeneric)elements.elementAt(lowToHighIndex);
       
   278 			}
       
   279 			highToLowValue = (ProfiledGeneric)elements.elementAt(highToLowIndex);
       
   280 			while (newHighIndex <= highToLowIndex)
       
   281 			{
       
   282 				// chose false is less than true
       
   283 				// when sortAscending is true, sort from false to true
       
   284 	      		boolean first  = highToLowValue.isEnabled(graphIndex);
       
   285 	      		boolean second = pivotValue.isEnabled(graphIndex);
       
   286 
       
   287 	      		if ((first == second) || ((first && !second) ^ sortAscending))
       
   288 	      			break;
       
   289 
       
   290 				newLowIndex = highToLowIndex;
       
   291 			    highToLowIndex --;
       
   292 			    highToLowValue = (ProfiledGeneric)elements.elementAt(highToLowIndex);
       
   293 			}
       
   294 
       
   295 			// swap if needed
       
   296 			if (lowToHighIndex == highToLowIndex)
       
   297 			{
       
   298 				newHighIndex = lowToHighIndex;
       
   299 			}
       
   300 			else if (lowToHighIndex < highToLowIndex)
       
   301 			{
       
   302 	      		boolean low  = lowToHighValue.isEnabled(graphIndex);
       
   303 	      		boolean high = highToLowValue.isEnabled(graphIndex);
       
   304 				if ((low == high) || ((!low & high) ^ sortAscending)) // swap even if equal
       
   305 				{
       
   306 					if (low != high) {
       
   307 				    	parking = lowToHighValue;
       
   308 				    	elements.setElementAt(highToLowValue, lowToHighIndex);
       
   309 				    	elements.setElementAt(parking, highToLowIndex);
       
   310 					}
       
   311 
       
   312 			      	newLowIndex = highToLowIndex;
       
   313 			      	newHighIndex = lowToHighIndex;
       
   314 
       
   315 			      	lowToHighIndex ++;
       
   316 			      	highToLowIndex --;
       
   317 				}
       
   318 			}
       
   319 	    }
       
   320 
       
   321 	    // Continue recursion for parts that have more than one element
       
   322 	    if (lowIndex < newHighIndex)
       
   323 	    {
       
   324 	    	this.quickSortByShow(elements, lowIndex, newHighIndex); // sort lower subpart
       
   325 	    }
       
   326 	    if (newLowIndex < highIndex)
       
   327 	    {
       
   328 	    	this.quickSortByShow(elements, newLowIndex, highIndex); // sort higher subpart
       
   329 	    }
       
   330 	}
       
   331 
       
   332 	private void quickSortByAverageLoad(Vector<ProfiledGeneric> elements, int lowIndex, int highIndex)
       
   333 	{
       
   334 		int lowToHighIndex;
       
   335 		int highToLowIndex;
       
   336 		int pivotIndex;
       
   337 		ProfiledGeneric pivotValue;  // change the values to suit your application
       
   338 		ProfiledGeneric lowToHighValue;
       
   339 		ProfiledGeneric highToLowValue;
       
   340 		ProfiledGeneric parking;
       
   341 		int newLowIndex;
       
   342 		int newHighIndex;
       
   343 
       
   344 		lowToHighIndex = lowIndex;
       
   345 		highToLowIndex = highIndex;
       
   346 		pivotIndex = (lowToHighIndex + highToLowIndex) / 2;
       
   347 		pivotValue = (ProfiledGeneric) elements.elementAt(pivotIndex);
       
   348 
       
   349 		newLowIndex = highIndex + 1;
       
   350 		newHighIndex = lowIndex - 1;
       
   351 		// loop until low meets high
       
   352 		while ((newHighIndex + 1) < newLowIndex) // loop until partition complete
       
   353 		{
       
   354 		  	lowToHighValue = (ProfiledGeneric)elements.elementAt(lowToHighIndex);
       
   355 		  	while (lowToHighIndex < newLowIndex)
       
   356 		  	{
       
   357 		  		float first  = lowToHighValue.getPercentLoad(graphIndex);
       
   358 		    	float second = pivotValue.getPercentLoad(graphIndex);
       
   359 
       
   360 		    	if ((first == second) || ((first < second) ^ sortAscending))
       
   361 		    		break;
       
   362 
       
   363 			    newHighIndex = lowToHighIndex; // add element to lower part
       
   364 			    lowToHighIndex ++;
       
   365 			    lowToHighValue = (ProfiledGeneric)elements.elementAt(lowToHighIndex);
       
   366 			}
       
   367 
       
   368 		    highToLowValue = (ProfiledGeneric)elements.elementAt(highToLowIndex);
       
   369 		    while (newHighIndex <= highToLowIndex)
       
   370 		    {
       
   371 		    	float first  = highToLowValue.getPercentLoad(graphIndex);
       
   372 		    	float second = pivotValue.getPercentLoad(graphIndex);
       
   373 
       
   374 			    if ((first == second) || ((first > second) ^ sortAscending))
       
   375 			    	break;
       
   376 
       
   377 			    newLowIndex = highToLowIndex; // add element to higher part
       
   378 			    highToLowIndex --;
       
   379 			    highToLowValue = (ProfiledGeneric)elements.elementAt(highToLowIndex);
       
   380 		    }
       
   381 
       
   382 		    // swap if needed
       
   383 		    if (lowToHighIndex == highToLowIndex) // one last element, may go in either part
       
   384 		    {
       
   385 				newHighIndex = lowToHighIndex; // move element arbitrary to lower part
       
   386 		    }
       
   387 		    else if (lowToHighIndex < highToLowIndex) // not last element yet
       
   388 		    {
       
   389 				float first  = lowToHighValue.getPercentLoad(graphIndex);
       
   390 				float second = highToLowValue.getPercentLoad(graphIndex);
       
   391 				if ((first == second) || ((first < second) ^ sortAscending))
       
   392 			    {
       
   393 			       	if (first != second) {
       
   394 			       		parking = lowToHighValue;
       
   395 				        elements.setElementAt(highToLowValue, lowToHighIndex);
       
   396 				        elements.setElementAt(parking, highToLowIndex);
       
   397 			       	}
       
   398 
       
   399 				    newLowIndex = highToLowIndex;
       
   400 				    newHighIndex = lowToHighIndex;
       
   401 
       
   402 				    lowToHighIndex ++;
       
   403 				    highToLowIndex --;
       
   404 			    }
       
   405 		    }
       
   406 		}
       
   407 
       
   408 		// Continue recursion for parts that have more than one element
       
   409 		if (lowIndex < newHighIndex)
       
   410 		{
       
   411 		  	// sort lower subpart
       
   412 		  	this.quickSortByAverageLoad(elements, lowIndex, newHighIndex);
       
   413 		}
       
   414 		if (newLowIndex < highIndex)
       
   415 		{
       
   416 		  	// sort higher subpart
       
   417 		  	this.quickSortByAverageLoad(elements, newLowIndex, highIndex);
       
   418 		}
       
   419 	}
       
   420 
       
   421 	private void quickSortByName(Vector<ProfiledGeneric> elements, int lowIndex, int highIndex, boolean caseSensitive)
       
   422 	{
       
   423 		int lowToHighIndex;
       
   424 	    int highToLowIndex;
       
   425 	    int pivotIndex;
       
   426 	    ProfiledGeneric pivotValue;  // change the values to suit your application
       
   427 	    ProfiledGeneric lowToHighValue;
       
   428 	    ProfiledGeneric highToLowValue;
       
   429 	    ProfiledGeneric parking;
       
   430 	    int newLowIndex;
       
   431 	    int newHighIndex;
       
   432 	    int compareResult;
       
   433 
       
   434 	    lowToHighIndex = lowIndex;
       
   435 	    highToLowIndex = highIndex;
       
   436 
       
   437 	    pivotIndex = (lowToHighIndex + highToLowIndex) / 2;
       
   438 	    pivotValue = (ProfiledGeneric)elements.elementAt(pivotIndex);
       
   439 
       
   440 	    newLowIndex = highIndex + 1;
       
   441 	    newHighIndex = lowIndex - 1;
       
   442 	    while ((newHighIndex + 1) < newLowIndex)
       
   443 	    {
       
   444 			lowToHighValue = (ProfiledGeneric)elements.elementAt(lowToHighIndex);
       
   445 			while (lowToHighIndex < newLowIndex)
       
   446 			{
       
   447 				if (caseSensitive)
       
   448 					compareResult = lowToHighValue.getNameString().compareTo(pivotValue.getNameString());
       
   449 				else
       
   450 					compareResult = lowToHighValue.getNameString().compareToIgnoreCase(pivotValue.getNameString());
       
   451 					
       
   452 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
   453 					break;
       
   454 
       
   455 				newHighIndex = lowToHighIndex;
       
   456 			    lowToHighIndex ++;
       
   457 			    lowToHighValue = (ProfiledGeneric)elements.elementAt(lowToHighIndex);
       
   458 			}
       
   459 			highToLowValue = (ProfiledGeneric)elements.elementAt(highToLowIndex);
       
   460 			while (newHighIndex <= highToLowIndex)
       
   461 			{
       
   462 				if (caseSensitive)
       
   463 					compareResult = highToLowValue.getNameString().compareTo(pivotValue.getNameString());
       
   464 				else
       
   465 					compareResult = highToLowValue.getNameString().compareToIgnoreCase(pivotValue.getNameString());
       
   466 					
       
   467 				if ((compareResult == 0) || ((compareResult > 0) ^ sortAscending))
       
   468 					break;
       
   469 
       
   470 				newLowIndex = highToLowIndex;
       
   471 			    highToLowIndex --;
       
   472 			    highToLowValue = (ProfiledGeneric)elements.elementAt(highToLowIndex);
       
   473 			}
       
   474 
       
   475 			// swap if needed
       
   476 			if (lowToHighIndex == highToLowIndex)
       
   477 			{
       
   478 				newHighIndex = lowToHighIndex;
       
   479 			}
       
   480 			else if (lowToHighIndex < highToLowIndex)
       
   481 			{
       
   482 				if (caseSensitive)
       
   483 					compareResult = lowToHighValue.getNameString().compareTo(highToLowValue.getNameString());
       
   484 				else
       
   485 					compareResult = lowToHighValue.getNameString().compareToIgnoreCase(highToLowValue.getNameString());
       
   486 					
       
   487 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
   488 				{
       
   489 			    	if (compareResult != 0) {
       
   490 			    		parking = lowToHighValue;
       
   491 				    	elements.setElementAt(highToLowValue, lowToHighIndex);
       
   492 				    	elements.setElementAt(parking, highToLowIndex);
       
   493 			    	}
       
   494 
       
   495 			      	newLowIndex = highToLowIndex;
       
   496 			      	newHighIndex = lowToHighIndex;
       
   497 
       
   498 			      	lowToHighIndex ++;
       
   499 			      	highToLowIndex --;
       
   500 				}
       
   501 			}
       
   502 	    }
       
   503 
       
   504 	    // Continue recursion for parts that have more than one element
       
   505 	    if (lowIndex < newHighIndex)
       
   506 	    {
       
   507 	    	this.quickSortByName(elements, lowIndex, newHighIndex, caseSensitive); // sort lower subpart
       
   508 	    }
       
   509 	    if (newLowIndex < highIndex)
       
   510 	    {
       
   511 	    	this.quickSortByName(elements, newLowIndex, highIndex, caseSensitive); // sort higher subpart
       
   512 	    }
       
   513 	}
       
   514 
       
   515 	private void quickSortByBinary(Vector<ProfiledGeneric> elements, int lowIndex, int highIndex)
       
   516 	{
       
   517 		int lowToHighIndex;
       
   518 	    int highToLowIndex;
       
   519 	    int pivotIndex;
       
   520 	    ProfiledGeneric pivotValue;  // change the values to suit your application
       
   521 	    ProfiledGeneric lowToHighValue;
       
   522 	    ProfiledGeneric highToLowValue;
       
   523 	    ProfiledGeneric parking;
       
   524 	    int newLowIndex;
       
   525 	    int newHighIndex;
       
   526 	    int compareResult;
       
   527 
       
   528 	    lowToHighIndex = lowIndex;
       
   529 	    highToLowIndex = highIndex;
       
   530 
       
   531 	    pivotIndex = (lowToHighIndex + highToLowIndex) / 2;
       
   532 	    pivotValue = (ProfiledGeneric)elements.elementAt(pivotIndex);
       
   533 
       
   534 	    String pivotName = pivotValue.getNameString();
       
   535 		int index = pivotName.lastIndexOf('\\');
       
   536 		if (index != -1)
       
   537 			pivotName = pivotName.substring(index);
       
   538 
       
   539 	    newLowIndex = highIndex + 1;
       
   540 	    newHighIndex = lowIndex - 1;
       
   541 	    while ((newHighIndex + 1) < newLowIndex)
       
   542 	    {
       
   543 			lowToHighValue = (ProfiledGeneric)elements.elementAt(lowToHighIndex);
       
   544 			while (lowToHighIndex < newLowIndex)
       
   545 			{
       
   546 				String lowName = lowToHighValue.getNameString();
       
   547 				index = lowName.lastIndexOf('\\');
       
   548 				if (index != -1)
       
   549 					lowName = lowName.substring(index);
       
   550 
       
   551 				compareResult = lowName.compareToIgnoreCase(pivotName);
       
   552 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
   553 					break;
       
   554 
       
   555 				newHighIndex = lowToHighIndex;
       
   556 			    lowToHighIndex ++;
       
   557 			    lowToHighValue = (ProfiledGeneric)elements.elementAt(lowToHighIndex);
       
   558 			}
       
   559 			highToLowValue = (ProfiledGeneric)elements.elementAt(highToLowIndex);
       
   560 			while (newHighIndex <= highToLowIndex)
       
   561 			{
       
   562 				String highName = highToLowValue.getNameString();
       
   563 				index = highName.lastIndexOf('\\');
       
   564 				if (index != -1)
       
   565 					highName = highName.substring(index);
       
   566 
       
   567 				compareResult = highName.compareToIgnoreCase(pivotName);
       
   568 				if ((compareResult == 0) || ((compareResult > 0) ^ sortAscending))
       
   569 					break;
       
   570 
       
   571 				newLowIndex = highToLowIndex;
       
   572 			    highToLowIndex --;
       
   573 			    highToLowValue = (ProfiledGeneric)elements.elementAt(highToLowIndex);
       
   574 			}
       
   575 
       
   576 			// swap if needed
       
   577 			if (lowToHighIndex == highToLowIndex)
       
   578 			{
       
   579 				newHighIndex = lowToHighIndex;
       
   580 			}
       
   581 			else if (lowToHighIndex < highToLowIndex)
       
   582 			{
       
   583 				String lowName = lowToHighValue.getNameString();
       
   584 				index = lowName.lastIndexOf('\\');
       
   585 				if (index != -1)
       
   586 					lowName = lowName.substring(index);
       
   587 
       
   588 				String highName = highToLowValue.getNameString();
       
   589 				index = highName.lastIndexOf('\\');
       
   590 				if (index != -1)
       
   591 					highName = highName.substring(index);
       
   592 
       
   593 				compareResult = lowName.compareToIgnoreCase(highName);
       
   594 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
   595 				{
       
   596 			    	if (compareResult != 0) {
       
   597 			    		parking = lowToHighValue;
       
   598 				    	elements.setElementAt(highToLowValue, lowToHighIndex);
       
   599 				    	elements.setElementAt(parking, highToLowIndex);
       
   600 			    	}
       
   601 
       
   602 			      	newLowIndex = highToLowIndex;
       
   603 			      	newHighIndex = lowToHighIndex;
       
   604 
       
   605 			      	lowToHighIndex ++;
       
   606 			      	highToLowIndex --;
       
   607 				}
       
   608 			}
       
   609 	    }
       
   610 
       
   611 	    // Continue recursion for parts that have more than one element
       
   612 	    if (lowIndex < newHighIndex)
       
   613 	    {
       
   614 	    	this.quickSortByBinary(elements, lowIndex, newHighIndex); // sort lower subpart
       
   615 	    }
       
   616 	    if (newLowIndex < highIndex)
       
   617 	    {
       
   618 	    	this.quickSortByBinary(elements, newLowIndex, highIndex); // sort higher subpart
       
   619 	    }
       
   620 	}
       
   621 
       
   622 	private void quickSortByBinaryPath(Vector<ProfiledGeneric> elements, int lowIndex, int highIndex)
       
   623 	{
       
   624 		int lowToHighIndex;
       
   625 	    int highToLowIndex;
       
   626 	    int pivotIndex;
       
   627 	    ProfiledGeneric pivotValue;  // change the values to suit your application
       
   628 	    ProfiledGeneric lowToHighValue;
       
   629 	    ProfiledGeneric highToLowValue;
       
   630 	    ProfiledGeneric parking;
       
   631 	    int newLowIndex;
       
   632 	    int newHighIndex;
       
   633 	    int compareResult;
       
   634 
       
   635 	    lowToHighIndex = lowIndex;
       
   636 	    highToLowIndex = highIndex;
       
   637 
       
   638 	    pivotIndex = (lowToHighIndex + highToLowIndex) / 2;
       
   639 	    pivotValue = (ProfiledGeneric)elements.elementAt(pivotIndex);
       
   640 
       
   641 		String pivotName = pivotValue.getNameString();
       
   642 		int index = pivotName.lastIndexOf('\\');
       
   643 		if (index == -1)
       
   644 			pivotName = ""; //$NON-NLS-1$
       
   645 		else
       
   646 			pivotName = pivotName.substring(0, index);
       
   647 
       
   648 	    newLowIndex = highIndex + 1;
       
   649 	    newHighIndex = lowIndex - 1;
       
   650 	    while ((newHighIndex + 1) < newLowIndex)
       
   651 	    {
       
   652 			lowToHighValue = (ProfiledGeneric)elements.elementAt(lowToHighIndex);
       
   653 			while (lowToHighIndex < newLowIndex)
       
   654 			{
       
   655 				String lowName = lowToHighValue.getNameString();
       
   656 				index = lowName.lastIndexOf('\\');
       
   657 				if (index == -1)
       
   658 					lowName = ""; //$NON-NLS-1$
       
   659 				else
       
   660 					lowName = lowName.substring(0, index);
       
   661 
       
   662 				compareResult = lowName.compareToIgnoreCase(pivotName);
       
   663 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
   664 					break;
       
   665 
       
   666 				newHighIndex = lowToHighIndex;
       
   667 			    lowToHighIndex ++;
       
   668 			    lowToHighValue = (ProfiledGeneric)elements.elementAt(lowToHighIndex);
       
   669 			}
       
   670 			highToLowValue = (ProfiledGeneric)elements.elementAt(highToLowIndex);
       
   671 			while (newHighIndex <= highToLowIndex)
       
   672 			{
       
   673 				String highName = highToLowValue.getNameString();
       
   674 				index = highName.lastIndexOf('\\');
       
   675 				if (index == -1)
       
   676 					highName = ""; //$NON-NLS-1$
       
   677 				else
       
   678 					highName = highName.substring(0, index);
       
   679 
       
   680 				compareResult = highName.compareToIgnoreCase(pivotName);
       
   681 				if ((compareResult == 0) || ((compareResult > 0) ^ sortAscending))
       
   682 					break;
       
   683 
       
   684 				newLowIndex = highToLowIndex;
       
   685 			    highToLowIndex --;
       
   686 			    highToLowValue = (ProfiledGeneric)elements.elementAt(highToLowIndex);
       
   687 			}
       
   688 
       
   689 			// swap if needed
       
   690 			if (lowToHighIndex == highToLowIndex)
       
   691 			{
       
   692 				newHighIndex = lowToHighIndex;
       
   693 			}
       
   694 			else if (lowToHighIndex < highToLowIndex)
       
   695 			{
       
   696 				String lowName = lowToHighValue.getNameString();
       
   697 				index = lowName.lastIndexOf('\\');
       
   698 				if (index == -1)
       
   699 					lowName = ""; //$NON-NLS-1$
       
   700 				else
       
   701 					lowName = lowName.substring(0, index);
       
   702 
       
   703 				String highName = highToLowValue.getNameString();
       
   704 				index = highName.lastIndexOf('\\');
       
   705 				if (index == -1)
       
   706 					highName = ""; //$NON-NLS-1$
       
   707 				else
       
   708 					highName = highName.substring(0, index);
       
   709 
       
   710 				compareResult = lowName.compareToIgnoreCase(highName);
       
   711 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
   712 				{
       
   713 			    	if (compareResult != 0) {
       
   714 			    		parking = lowToHighValue;
       
   715 				    	elements.setElementAt(highToLowValue, lowToHighIndex);
       
   716 				    	elements.setElementAt(parking, highToLowIndex);
       
   717 			    	}
       
   718 
       
   719 			      	newLowIndex = highToLowIndex;
       
   720 			      	newHighIndex = lowToHighIndex;
       
   721 
       
   722 			      	lowToHighIndex ++;
       
   723 			      	highToLowIndex --;
       
   724 				}
       
   725 			}
       
   726 	    }
       
   727 
       
   728 	    // Continue recursion for parts that have more than one element
       
   729 	    if (lowIndex < newHighIndex)
       
   730 	    {
       
   731 	    	this.quickSortByBinaryPath(elements, lowIndex, newHighIndex); // sort lower subpart
       
   732 	    }
       
   733 	    if (newLowIndex < highIndex)
       
   734 	    {
       
   735 	    	this.quickSortByBinaryPath(elements, newLowIndex, highIndex); // sort higher subpart
       
   736 	    }
       
   737 	}
       
   738 
       
   739 	private void quickSortByFullBinaryPath(Vector<ProfiledGeneric> elements, int lowIndex, int highIndex)
       
   740 	{
       
   741 		int lowToHighIndex;
       
   742 	    int highToLowIndex;
       
   743 	    int pivotIndex;
       
   744 	    ProfiledGeneric pivotValue;  // change the values to suit your application
       
   745 	    ProfiledGeneric lowToHighValue;
       
   746 	    ProfiledGeneric highToLowValue;
       
   747 	    ProfiledGeneric parking;
       
   748 	    int newLowIndex;
       
   749 	    int newHighIndex;
       
   750 	    int compareResult;
       
   751 
       
   752 	    lowToHighIndex = lowIndex;
       
   753 	    highToLowIndex = highIndex;
       
   754 
       
   755 	    pivotIndex = (lowToHighIndex + highToLowIndex) / 2;
       
   756 	    pivotValue = (ProfiledGeneric)elements.elementAt(pivotIndex);
       
   757 
       
   758 		String pivotName = pivotValue.getNameString();
       
   759 
       
   760 	    newLowIndex = highIndex + 1;
       
   761 	    newHighIndex = lowIndex - 1;
       
   762 	    while ((newHighIndex + 1) < newLowIndex)
       
   763 	    {
       
   764 			lowToHighValue = (ProfiledGeneric)elements.elementAt(lowToHighIndex);
       
   765 			while (lowToHighIndex < newLowIndex)
       
   766 			{
       
   767 				String lowName = lowToHighValue.getNameString();
       
   768 
       
   769 				compareResult = lowName.compareToIgnoreCase(pivotName);
       
   770 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
   771 					break;
       
   772 
       
   773 				newHighIndex = lowToHighIndex;
       
   774 			    lowToHighIndex ++;
       
   775 			    lowToHighValue = (ProfiledGeneric)elements.elementAt(lowToHighIndex);
       
   776 			}
       
   777 			highToLowValue = (ProfiledGeneric)elements.elementAt(highToLowIndex);
       
   778 			while (newHighIndex <= highToLowIndex)
       
   779 			{
       
   780 				String highName = highToLowValue.getNameString();
       
   781 
       
   782 				compareResult = highName.compareToIgnoreCase(pivotName);
       
   783 				if ((compareResult == 0) || ((compareResult > 0) ^ sortAscending))
       
   784 					break;
       
   785 
       
   786 				newLowIndex = highToLowIndex;
       
   787 			    highToLowIndex --;
       
   788 			    highToLowValue = (ProfiledGeneric)elements.elementAt(highToLowIndex);
       
   789 			}
       
   790 
       
   791 			// swap if needed
       
   792 			if (lowToHighIndex == highToLowIndex)
       
   793 			{
       
   794 				newHighIndex = lowToHighIndex;
       
   795 			}
       
   796 			else if (lowToHighIndex < highToLowIndex)
       
   797 			{
       
   798 				String lowName = lowToHighValue.getNameString();
       
   799 				String highName = highToLowValue.getNameString();
       
   800 
       
   801 				compareResult = lowName.compareToIgnoreCase(highName);
       
   802 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
   803 				{
       
   804 			    	if (compareResult != 0) {
       
   805 			    		parking = lowToHighValue;
       
   806 				    	elements.setElementAt(highToLowValue, lowToHighIndex);
       
   807 				    	elements.setElementAt(parking, highToLowIndex);
       
   808 			    	}
       
   809 
       
   810 			      	newLowIndex = highToLowIndex;
       
   811 			      	newHighIndex = lowToHighIndex;
       
   812 
       
   813 			      	lowToHighIndex ++;
       
   814 			      	highToLowIndex --;
       
   815 				}
       
   816 			}
       
   817 	    }
       
   818 
       
   819 	    // Continue recursion for parts that have more than one element
       
   820 	    if (lowIndex < newHighIndex)
       
   821 	    {
       
   822 	    	this.quickSortByFullBinaryPath(elements, lowIndex, newHighIndex); // sort lower subpart
       
   823 	    }
       
   824 	    if (newLowIndex < highIndex)
       
   825 	    {
       
   826 	    	this.quickSortByFullBinaryPath(elements, newLowIndex, highIndex); // sort higher subpart
       
   827 	    }
       
   828 	}
       
   829 
       
   830 	private void quickSortByStartAddress(Vector<ProfiledGeneric> elements, int lowIndex, int highIndex)
       
   831 	{
       
   832 		int lowToHighIndex;
       
   833 	    int highToLowIndex;
       
   834 	    int pivotIndex;
       
   835 	    ProfiledFunction pivotValue;  // change the values to suit your application
       
   836 	    ProfiledFunction lowToHighValue;
       
   837 	    ProfiledFunction highToLowValue;
       
   838 	    ProfiledFunction parking;
       
   839 	    int newLowIndex;
       
   840 	    int newHighIndex;
       
   841 
       
   842 	    lowToHighIndex = lowIndex;
       
   843 	    highToLowIndex = highIndex;
       
   844 
       
   845 	    pivotIndex = (lowToHighIndex + highToLowIndex) / 2;
       
   846 	    pivotValue = (ProfiledFunction)elements.elementAt(pivotIndex);
       
   847 
       
   848 	    newLowIndex = highIndex + 1;
       
   849 	    newHighIndex = lowIndex - 1;
       
   850 	    while ((newHighIndex + 1) < newLowIndex)
       
   851 	    {
       
   852 			lowToHighValue = (ProfiledFunction)elements.elementAt(lowToHighIndex);
       
   853 			while (lowToHighIndex < newLowIndex)
       
   854 			{
       
   855 	      		long first  = lowToHighValue.getFunctionAddress();
       
   856 	      		long second = pivotValue.getFunctionAddress();
       
   857 
       
   858 	      		if ((first == second) || ((first < second) ^ sortAscending))
       
   859 	      			break;
       
   860 
       
   861 				newHighIndex = lowToHighIndex;
       
   862 			    lowToHighIndex ++;
       
   863 			    lowToHighValue = (ProfiledFunction)elements.elementAt(lowToHighIndex);
       
   864 			}
       
   865 			highToLowValue = (ProfiledFunction)elements.elementAt(highToLowIndex);
       
   866 			while (newHighIndex <= highToLowIndex)
       
   867 			{
       
   868 		      	long first  = highToLowValue.getFunctionAddress();
       
   869 		      	long second = pivotValue.getFunctionAddress();
       
   870 
       
   871 		      	if ((first == second) || ((first > second) ^ sortAscending))
       
   872 		      		break;
       
   873 
       
   874 				newLowIndex = highToLowIndex;
       
   875 			    highToLowIndex --;
       
   876 			    highToLowValue = (ProfiledFunction)elements.elementAt(highToLowIndex);
       
   877 			}
       
   878 
       
   879 			// swap if needed
       
   880 			if (lowToHighIndex == highToLowIndex)
       
   881 			{
       
   882 				newHighIndex = lowToHighIndex;
       
   883 			}
       
   884 			else if (lowToHighIndex < highToLowIndex)
       
   885 			{
       
   886 			    long first  = lowToHighValue.getFunctionAddress();
       
   887 			    long second = highToLowValue.getFunctionAddress();
       
   888 
       
   889 			    if ((first == second) || ((first < second) ^ sortAscending))
       
   890 				{
       
   891 			    	if (first != second) {
       
   892 			    		parking = lowToHighValue;
       
   893 				    	elements.setElementAt(highToLowValue, lowToHighIndex);
       
   894 				    	elements.setElementAt(parking, highToLowIndex);
       
   895 			    	}
       
   896 
       
   897 			      	newLowIndex = highToLowIndex;
       
   898 			      	newHighIndex = lowToHighIndex;
       
   899 
       
   900 			      	lowToHighIndex ++;
       
   901 			      	highToLowIndex --;
       
   902 				}
       
   903 			}
       
   904 	    }
       
   905 
       
   906 	    // Continue recursion for parts that have more than one element
       
   907 	    if (lowIndex < newHighIndex)
       
   908 	    {
       
   909 	    	this.quickSortByStartAddress(elements, lowIndex, newHighIndex); // sort lower subpart
       
   910 	    }
       
   911 	    if (newLowIndex < highIndex)
       
   912 	    {
       
   913 	    	this.quickSortByStartAddress(elements, newLowIndex, highIndex); // sort higher subpart
       
   914 	    }
       
   915 	}
       
   916 
       
   917 	private void quickSortByAssocBinary(Vector<ProfiledGeneric> elements, int lowIndex, int highIndex)
       
   918 	{
       
   919 		int lowToHighIndex;
       
   920 	    int highToLowIndex;
       
   921 	    int pivotIndex;
       
   922 	    ProfiledFunction pivotValue;  // change the values to suit your application
       
   923 	    ProfiledFunction lowToHighValue;
       
   924 	    ProfiledFunction highToLowValue;
       
   925 	    ProfiledFunction parking;
       
   926 	    int newLowIndex;
       
   927 	    int newHighIndex;
       
   928 	    int compareResult;
       
   929 
       
   930 	    lowToHighIndex = lowIndex;
       
   931 	    highToLowIndex = highIndex;
       
   932 
       
   933 	    pivotIndex = (lowToHighIndex + highToLowIndex) / 2;
       
   934 	    pivotValue = (ProfiledFunction)elements.elementAt(pivotIndex);
       
   935 
       
   936 	    String pivotName = pivotValue.getFunctionBinaryName();
       
   937 		int index = pivotName.lastIndexOf('\\');
       
   938 		if (index != -1)
       
   939 			pivotName = pivotName.substring(index);
       
   940 
       
   941 	    newLowIndex = highIndex + 1;
       
   942 	    newHighIndex = lowIndex - 1;
       
   943 	    while ((newHighIndex + 1) < newLowIndex)
       
   944 	    {
       
   945 			lowToHighValue = (ProfiledFunction)elements.elementAt(lowToHighIndex);
       
   946 			while (lowToHighIndex < newLowIndex)
       
   947 			{
       
   948 				String lowName = lowToHighValue.getFunctionBinaryName();
       
   949 				index = lowName.lastIndexOf('\\');
       
   950 				if (index != -1)
       
   951 					lowName = lowName.substring(index);
       
   952 
       
   953 				compareResult = lowName.compareToIgnoreCase(pivotName);
       
   954 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
   955 					break;
       
   956 
       
   957 				newHighIndex = lowToHighIndex;
       
   958 			    lowToHighIndex ++;
       
   959 			    lowToHighValue = (ProfiledFunction)elements.elementAt(lowToHighIndex);
       
   960 			}
       
   961 			highToLowValue = (ProfiledFunction)elements.elementAt(highToLowIndex);
       
   962 			while (newHighIndex <= highToLowIndex)
       
   963 			{
       
   964 				String highName = highToLowValue.getFunctionBinaryName();
       
   965 				index = highName.lastIndexOf('\\');
       
   966 				if (index != -1)
       
   967 					highName = highName.substring(index);
       
   968 
       
   969 				compareResult = highName.compareToIgnoreCase(pivotName);
       
   970 				if ((compareResult == 0) || ((compareResult > 0) ^ sortAscending))
       
   971 					break;
       
   972 
       
   973 				newLowIndex = highToLowIndex;
       
   974 			    highToLowIndex --;
       
   975 			    highToLowValue = (ProfiledFunction)elements.elementAt(highToLowIndex);
       
   976 			}
       
   977 
       
   978 			// swap if needed
       
   979 			if (lowToHighIndex == highToLowIndex)
       
   980 			{
       
   981 				newHighIndex = lowToHighIndex;
       
   982 			}
       
   983 			else if (lowToHighIndex < highToLowIndex)
       
   984 			{
       
   985 				String lowName = lowToHighValue.getFunctionBinaryName();
       
   986 				index = lowName.lastIndexOf('\\');
       
   987 				if (index != -1)
       
   988 					lowName = lowName.substring(index);
       
   989 
       
   990 				String highName = highToLowValue.getFunctionBinaryName();
       
   991 				index = highName.lastIndexOf('\\');
       
   992 				if (index != -1)
       
   993 					highName = highName.substring(index);
       
   994 
       
   995 				compareResult = lowName.compareToIgnoreCase(highName);
       
   996 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
   997 				{
       
   998 					if (compareResult != 0) {
       
   999 				    	parking = lowToHighValue;
       
  1000 				    	elements.setElementAt(highToLowValue, lowToHighIndex);
       
  1001 				    	elements.setElementAt(parking, highToLowIndex);
       
  1002 					}
       
  1003 
       
  1004 			      	newLowIndex = highToLowIndex;
       
  1005 			      	newHighIndex = lowToHighIndex;
       
  1006 
       
  1007 			      	lowToHighIndex ++;
       
  1008 			      	highToLowIndex --;
       
  1009 				}
       
  1010 			}
       
  1011 	    }
       
  1012 
       
  1013 	    // Continue recursion for parts that have more than one element
       
  1014 	    if (lowIndex < newHighIndex)
       
  1015 	    {
       
  1016 	    	this.quickSortByAssocBinary(elements, lowIndex, newHighIndex); // sort lower subpart
       
  1017 	    }
       
  1018 	    if (newLowIndex < highIndex)
       
  1019 	    {
       
  1020 	    	this.quickSortByAssocBinary(elements, newLowIndex, highIndex); // sort higher subpart
       
  1021 	    }
       
  1022 	}
       
  1023 
       
  1024 	private void quickSortByAssocBinaryPath(Vector<ProfiledGeneric> elements, int lowIndex, int highIndex)
       
  1025 	{
       
  1026 		int lowToHighIndex;
       
  1027 	    int highToLowIndex;
       
  1028 	    int pivotIndex;
       
  1029 	    ProfiledFunction pivotValue;  // change the values to suit your application
       
  1030 	    ProfiledFunction lowToHighValue;
       
  1031 	    ProfiledFunction highToLowValue;
       
  1032 	    ProfiledFunction parking;
       
  1033 	    int newLowIndex;
       
  1034 	    int newHighIndex;
       
  1035 	    int compareResult;
       
  1036 
       
  1037 	    lowToHighIndex = lowIndex;
       
  1038 	    highToLowIndex = highIndex;
       
  1039 
       
  1040 	    pivotIndex = (lowToHighIndex + highToLowIndex) / 2;
       
  1041 	    pivotValue = (ProfiledFunction)elements.elementAt(pivotIndex);
       
  1042 
       
  1043 		String pivotName = pivotValue.getFunctionBinaryName();
       
  1044 		int index = pivotName.lastIndexOf('\\');
       
  1045 		if (index == -1)
       
  1046 			pivotName = ""; //$NON-NLS-1$
       
  1047 		else
       
  1048 			pivotName = pivotName.substring(0, index);
       
  1049 
       
  1050 	    newLowIndex = highIndex + 1;
       
  1051 	    newHighIndex = lowIndex - 1;
       
  1052 	    while ((newHighIndex + 1) < newLowIndex)
       
  1053 	    {
       
  1054 			lowToHighValue = (ProfiledFunction)elements.elementAt(lowToHighIndex);
       
  1055 			while (lowToHighIndex < newLowIndex)
       
  1056 			{
       
  1057 				String lowName = lowToHighValue.getFunctionBinaryName();
       
  1058 				index = lowName.lastIndexOf('\\');
       
  1059 				if (index == -1)
       
  1060 					lowName = ""; //$NON-NLS-1$
       
  1061 				else
       
  1062 					lowName = lowName.substring(0, index);
       
  1063 
       
  1064 				compareResult = lowName.compareToIgnoreCase(pivotName);
       
  1065 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
  1066 					break;
       
  1067 
       
  1068 				newHighIndex = lowToHighIndex;
       
  1069 			    lowToHighIndex ++;
       
  1070 			    lowToHighValue = (ProfiledFunction)elements.elementAt(lowToHighIndex);
       
  1071 			}
       
  1072 			highToLowValue = (ProfiledFunction)elements.elementAt(highToLowIndex);
       
  1073 			while (newHighIndex <= highToLowIndex)
       
  1074 			{
       
  1075 				String highName = highToLowValue.getFunctionBinaryName();
       
  1076 				index = highName.lastIndexOf('\\');
       
  1077 				if (index == -1)
       
  1078 					highName = ""; //$NON-NLS-1$
       
  1079 				else
       
  1080 					highName = highName.substring(0, index);
       
  1081 
       
  1082 				compareResult = highName.compareToIgnoreCase(pivotName);
       
  1083 				if ((compareResult == 0) || ((compareResult > 0) ^ sortAscending))
       
  1084 					break;
       
  1085 
       
  1086 				newLowIndex = highToLowIndex;
       
  1087 			    highToLowIndex --;
       
  1088 			    highToLowValue = (ProfiledFunction)elements.elementAt(highToLowIndex);
       
  1089 			}
       
  1090 
       
  1091 			// swap if needed
       
  1092 			if (lowToHighIndex == highToLowIndex)
       
  1093 			{
       
  1094 				newHighIndex = lowToHighIndex;
       
  1095 			}
       
  1096 			else if (lowToHighIndex < highToLowIndex)
       
  1097 			{
       
  1098 				String lowName = lowToHighValue.getFunctionBinaryName();
       
  1099 				index = lowName.lastIndexOf('\\');
       
  1100 				if (index == -1)
       
  1101 					lowName = ""; //$NON-NLS-1$
       
  1102 				else
       
  1103 					lowName = lowName.substring(0, index);
       
  1104 
       
  1105 				String highName = highToLowValue.getFunctionBinaryName();
       
  1106 				index = highName.lastIndexOf('\\');
       
  1107 				if (index == -1)
       
  1108 					highName = ""; //$NON-NLS-1$
       
  1109 				else
       
  1110 					highName = highName.substring(0, index);
       
  1111 
       
  1112 				compareResult = lowName.compareToIgnoreCase(highName);
       
  1113 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
  1114 				{
       
  1115 					if (compareResult != 0) {
       
  1116 				    	parking = lowToHighValue;
       
  1117 				    	elements.setElementAt(highToLowValue, lowToHighIndex);
       
  1118 				    	elements.setElementAt(parking, highToLowIndex);
       
  1119 					}
       
  1120 
       
  1121 			      	newLowIndex = highToLowIndex;
       
  1122 			      	newHighIndex = lowToHighIndex;
       
  1123 
       
  1124 			      	lowToHighIndex ++;
       
  1125 			      	highToLowIndex --;
       
  1126 				}
       
  1127 			}
       
  1128 	    }
       
  1129 
       
  1130 	    // Continue recursion for parts that have more than one element
       
  1131 	    if (lowIndex < newHighIndex)
       
  1132 	    {
       
  1133 	    	this.quickSortByAssocBinaryPath(elements, lowIndex, newHighIndex); // sort lower subpart
       
  1134 	    }
       
  1135 	    if (newLowIndex < highIndex)
       
  1136 	    {
       
  1137 	    	this.quickSortByAssocBinaryPath(elements, newLowIndex, highIndex); // sort higher subpart
       
  1138 	    }
       
  1139 	}
       
  1140 
       
  1141 	private void quickSortByFullAssocBinaryPath(Vector<ProfiledGeneric> elements, int lowIndex, int highIndex)
       
  1142 	{
       
  1143 		int lowToHighIndex;
       
  1144 	    int highToLowIndex;
       
  1145 	    int pivotIndex;
       
  1146 	    ProfiledFunction pivotValue;  // change the values to suit your application
       
  1147 	    ProfiledFunction lowToHighValue;
       
  1148 	    ProfiledFunction highToLowValue;
       
  1149 	    ProfiledFunction parking;
       
  1150 	    int newLowIndex;
       
  1151 	    int newHighIndex;
       
  1152 	    int compareResult;
       
  1153 
       
  1154 	    lowToHighIndex = lowIndex;
       
  1155 	    highToLowIndex = highIndex;
       
  1156 
       
  1157 	    pivotIndex = (lowToHighIndex + highToLowIndex) / 2;
       
  1158 	    pivotValue = (ProfiledFunction)elements.elementAt(pivotIndex);
       
  1159 
       
  1160 	    String pivotName = pivotValue.getFunctionBinaryName();
       
  1161 
       
  1162 	    newLowIndex = highIndex + 1;
       
  1163 	    newHighIndex = lowIndex - 1;
       
  1164 	    while ((newHighIndex + 1) < newLowIndex)
       
  1165 	    {
       
  1166 			lowToHighValue = (ProfiledFunction)elements.elementAt(lowToHighIndex);
       
  1167 			while (lowToHighIndex < newLowIndex)
       
  1168 			{
       
  1169 				String lowName = lowToHighValue.getFunctionBinaryName();
       
  1170 
       
  1171 				compareResult = lowName.compareToIgnoreCase(pivotName);
       
  1172 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
  1173 					break;
       
  1174 
       
  1175 				newHighIndex = lowToHighIndex;
       
  1176 			    lowToHighIndex ++;
       
  1177 			    lowToHighValue = (ProfiledFunction)elements.elementAt(lowToHighIndex);
       
  1178 			}
       
  1179 			highToLowValue = (ProfiledFunction)elements.elementAt(highToLowIndex);
       
  1180 			while (newHighIndex <= highToLowIndex)
       
  1181 			{
       
  1182 				String highName = highToLowValue.getFunctionBinaryName();
       
  1183 
       
  1184 				compareResult = highName.compareToIgnoreCase(pivotName);
       
  1185 				if ((compareResult == 0) || ((compareResult > 0) ^ sortAscending))
       
  1186 					break;
       
  1187 
       
  1188 				newLowIndex = highToLowIndex;
       
  1189 			    highToLowIndex --;
       
  1190 			    highToLowValue = (ProfiledFunction)elements.elementAt(highToLowIndex);
       
  1191 			}
       
  1192 
       
  1193 			// swap if needed
       
  1194 			if (lowToHighIndex == highToLowIndex)
       
  1195 			{
       
  1196 				newHighIndex = lowToHighIndex;
       
  1197 			}
       
  1198 			else if (lowToHighIndex < highToLowIndex)
       
  1199 			{
       
  1200 				String lowName = lowToHighValue.getFunctionBinaryName();
       
  1201 				String highName = highToLowValue.getFunctionBinaryName();
       
  1202 
       
  1203 				compareResult = lowName.compareToIgnoreCase(highName);
       
  1204 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
  1205 				{
       
  1206 					if (compareResult != 0) {
       
  1207 				    	parking = lowToHighValue;
       
  1208 				    	elements.setElementAt(highToLowValue, lowToHighIndex);
       
  1209 				    	elements.setElementAt(parking, highToLowIndex);
       
  1210 					}
       
  1211 
       
  1212 			      	newLowIndex = highToLowIndex;
       
  1213 			      	newHighIndex = lowToHighIndex;
       
  1214 
       
  1215 			      	lowToHighIndex ++;
       
  1216 			      	highToLowIndex --;
       
  1217 				}
       
  1218 			}
       
  1219 	    }
       
  1220 
       
  1221 	    // Continue recursion for parts that have more than one element
       
  1222 	    if (lowIndex < newHighIndex)
       
  1223 	    {
       
  1224 	    	this.quickSortByFullAssocBinaryPath(elements, lowIndex, newHighIndex); // sort lower subpart
       
  1225 	    }
       
  1226 	    if (newLowIndex < highIndex)
       
  1227 	    {
       
  1228 	    	this.quickSortByFullAssocBinaryPath(elements, newLowIndex, highIndex); // sort higher subpart
       
  1229 	    }
       
  1230 	}
       
  1231 
       
  1232 	private void quickSortByPriority(Vector<ProfiledGeneric> elements, int lowIndex, int highIndex, Hashtable priorities)
       
  1233 	{
       
  1234 		int lowToHighIndex;
       
  1235 		int highToLowIndex;
       
  1236 		int pivotIndex;
       
  1237 		ProfiledThread pivotValue;  // change the values to suit your application
       
  1238 		ProfiledThread lowToHighValue;
       
  1239 		ProfiledThread highToLowValue;
       
  1240 		ProfiledThread parking;
       
  1241 		int newLowIndex;
       
  1242 		int newHighIndex;
       
  1243 		int compareResult;
       
  1244 
       
  1245 		lowToHighIndex = lowIndex;
       
  1246 		highToLowIndex = highIndex;
       
  1247 		pivotIndex = (lowToHighIndex + highToLowIndex) / 2;
       
  1248 		pivotValue = (ProfiledThread)elements.elementAt(pivotIndex);
       
  1249 		Integer pivot = (Integer)priorities.get(new Integer(pivotValue.getThreadId()));
       
  1250 		pivot = (pivot == null) ? new Integer(Integer.MIN_VALUE) : pivot;
       
  1251 
       
  1252 		newLowIndex = highIndex + 1;
       
  1253 		newHighIndex = lowIndex - 1;
       
  1254 
       
  1255 		// loop until low meets high
       
  1256 		while ((newHighIndex + 1) < newLowIndex) // loop until partition complete
       
  1257 		{
       
  1258 			lowToHighValue = (ProfiledThread)elements.elementAt(lowToHighIndex);
       
  1259 			Integer low = (Integer)priorities.get(new Integer(lowToHighValue.getThreadId()));
       
  1260 			low = (low == null) ? new Integer(Integer.MIN_VALUE) : low;
       
  1261 			while (lowToHighIndex < newLowIndex
       
  1262 					&& ((low.compareTo(pivot) != 0) && ((low.compareTo(pivot) > 0) ^ sortAscending)))
       
  1263 			{
       
  1264 				newHighIndex = lowToHighIndex; // add element to lower part
       
  1265 				lowToHighIndex ++;
       
  1266 				lowToHighValue = (ProfiledThread)elements.elementAt(lowToHighIndex);
       
  1267 				low = (Integer)priorities.get(new Integer(lowToHighValue.getThreadId()));
       
  1268 				low = (low == null) ? new Integer(Integer.MIN_VALUE) : low;
       
  1269 			}
       
  1270 
       
  1271 			highToLowValue = (ProfiledThread)elements.elementAt(highToLowIndex);
       
  1272 			Integer high = (Integer)priorities.get(new Integer(highToLowValue.getThreadId()));
       
  1273 			high = (high == null) ? new Integer(Integer.MIN_VALUE) : high;
       
  1274 			while (newHighIndex <= highToLowIndex
       
  1275 					&& ((high.compareTo(pivot) != 0) && ((high.compareTo(pivot) < 0) ^ sortAscending)))
       
  1276 			{
       
  1277 				newLowIndex = highToLowIndex; // add element to higher part
       
  1278 				highToLowIndex --;
       
  1279 				highToLowValue = (ProfiledThread)elements.elementAt(highToLowIndex);
       
  1280 				high = (Integer)priorities.get(new Integer(highToLowValue.getThreadId()));
       
  1281 			  	high = (high == null) ? new Integer(Integer.MIN_VALUE) : high;
       
  1282 			}
       
  1283 
       
  1284 			// swap if needed
       
  1285 			if (lowToHighIndex == highToLowIndex) // one last element, may go in either part
       
  1286 			{
       
  1287 				newHighIndex = lowToHighIndex; // move element arbitrary to lower part
       
  1288 			}
       
  1289 			else if (lowToHighIndex < highToLowIndex) // not last element yet
       
  1290 			{
       
  1291 				high = (Integer)priorities.get(new Integer(highToLowValue.getThreadId()));
       
  1292 				high = (high == null) ? new Integer(Integer.MIN_VALUE) : high;
       
  1293 				low  = (Integer)priorities.get(new Integer(lowToHighValue.getThreadId()));
       
  1294 				low  = (low == null) ? new Integer(Integer.MIN_VALUE) : low;
       
  1295 
       
  1296 				compareResult = low.compareTo(high);
       
  1297 				if ((compareResult == 0) || ((compareResult < 0) ^ sortAscending))
       
  1298 				{
       
  1299 					if (compareResult != 0) {
       
  1300 						parking = lowToHighValue;
       
  1301 						elements.setElementAt(highToLowValue, lowToHighIndex);
       
  1302 						elements.setElementAt(parking, highToLowIndex);
       
  1303 					}
       
  1304 
       
  1305 					newLowIndex = highToLowIndex;
       
  1306 					newHighIndex = lowToHighIndex;
       
  1307 
       
  1308 					lowToHighIndex ++;
       
  1309 					highToLowIndex --;
       
  1310 				}
       
  1311 			}
       
  1312 		}
       
  1313 
       
  1314 		// Continue recursion for parts that have more than one element
       
  1315 		if (lowIndex < newHighIndex)
       
  1316 		{
       
  1317 			this.quickSortByPriority(elements, lowIndex, newHighIndex, priorities); // sort lower subpart
       
  1318 		}
       
  1319 		if (newLowIndex < highIndex)
       
  1320 		{
       
  1321 			this.quickSortByPriority(elements, newLowIndex, highIndex, priorities); // sort higher subpart
       
  1322 		}
       
  1323 	}
       
  1324 
       
  1325 	private void quickSortBySampleCount(Vector<ProfiledGeneric> elements, int lowIndex, int highIndex)
       
  1326 	{
       
  1327 	  	int lowToHighIndex;
       
  1328 	    int highToLowIndex;
       
  1329 	    int pivotIndex;
       
  1330 	    ProfiledGeneric pivotValue;  // change the values to suit your application
       
  1331 	    ProfiledGeneric lowToHighValue;
       
  1332 	    ProfiledGeneric highToLowValue;
       
  1333 	    ProfiledGeneric parking;
       
  1334 	    int newLowIndex;
       
  1335 	    int newHighIndex;
       
  1336 
       
  1337 	    lowToHighIndex = lowIndex;
       
  1338 	    highToLowIndex = highIndex;
       
  1339 	    pivotIndex = (lowToHighIndex + highToLowIndex) / 2;
       
  1340 	    pivotValue = (ProfiledGeneric) elements.elementAt(pivotIndex);
       
  1341 
       
  1342 	    newLowIndex = highIndex + 1;
       
  1343 	    newHighIndex = lowIndex - 1;
       
  1344 	    // loop until low meets high
       
  1345 	    while ((newHighIndex + 1) < newLowIndex) // loop until partition complete
       
  1346 	    {
       
  1347 	    	lowToHighValue = (ProfiledGeneric)elements.elementAt(lowToHighIndex);
       
  1348 	      	while (lowToHighIndex < newLowIndex)
       
  1349 		    {
       
  1350 	      		int first  = lowToHighValue.getSampleCount(graphIndex);
       
  1351 	      		int second = pivotValue.getSampleCount(graphIndex);
       
  1352 
       
  1353 	      		if ((first == second) || ((first < second) ^ sortAscending))
       
  1354 	      			break;
       
  1355 
       
  1356 		      	newHighIndex = lowToHighIndex; // add element to lower part
       
  1357 		        lowToHighIndex ++;
       
  1358 		        lowToHighValue = (ProfiledGeneric)elements.elementAt(lowToHighIndex);
       
  1359 		    }
       
  1360 
       
  1361 	      	highToLowValue = (ProfiledGeneric)elements.elementAt(highToLowIndex);
       
  1362 		    while (newHighIndex <= highToLowIndex)
       
  1363 		    {
       
  1364 		    	int first  = highToLowValue.getSampleCount(graphIndex);
       
  1365 			    int second = pivotValue.getSampleCount(graphIndex);
       
  1366 
       
  1367 			    if ((first == second) || ((first > second) ^ sortAscending))
       
  1368 			     	break;
       
  1369 
       
  1370 			    newLowIndex = highToLowIndex; // add element to higher part
       
  1371 			    highToLowIndex --;
       
  1372 			    highToLowValue = (ProfiledGeneric)elements.elementAt(highToLowIndex);
       
  1373 		   }
       
  1374 
       
  1375 		   // swap if needed
       
  1376 		   if (lowToHighIndex == highToLowIndex) // one last element, may go in either part
       
  1377 		   {
       
  1378 			    newHighIndex = lowToHighIndex; // move element arbitrary to lower part
       
  1379 		   }
       
  1380 		   else if (lowToHighIndex < highToLowIndex) // not last element yet
       
  1381 		   {
       
  1382 				int first  = lowToHighValue.getSampleCount(graphIndex);
       
  1383 				int second = highToLowValue.getSampleCount(graphIndex);
       
  1384 				if ((first == second) || ((first < second) ^ sortAscending))
       
  1385 			    {
       
  1386 					if (first != second) {
       
  1387 						parking = lowToHighValue;
       
  1388 					    elements.setElementAt(highToLowValue, lowToHighIndex);
       
  1389 					    elements.setElementAt(parking, highToLowIndex);
       
  1390 					}
       
  1391 
       
  1392 				    newLowIndex = highToLowIndex;
       
  1393 				    newHighIndex = lowToHighIndex;
       
  1394 
       
  1395 				    lowToHighIndex ++;
       
  1396 				    highToLowIndex --;
       
  1397 			    }
       
  1398 		   }
       
  1399 	    }
       
  1400 
       
  1401 		// Continue recursion for parts that have more than one element
       
  1402 		if (lowIndex < newHighIndex)
       
  1403 		{
       
  1404 			// sort lower subpart
       
  1405 		    this.quickSortBySampleCount(elements, lowIndex, newHighIndex);
       
  1406 		}
       
  1407 		if (newLowIndex < highIndex)
       
  1408 		{
       
  1409 		    // sort higher subpart
       
  1410 		    this.quickSortBySampleCount(elements, newLowIndex, highIndex);
       
  1411 	    }
       
  1412 	}
       
  1413 
       
  1414 	public Vector<ProfiledGeneric> getSortedList()
       
  1415 	{
       
  1416 		return sortedList;
       
  1417 	}
       
  1418 
       
  1419 }