11/**
22 * File created by Philip Hoang 06.2.
3- * written by Øyvind ;););)
3+ * written by Øyvind
44 * based on QuickFind.Java
55 */
66///<reference path="Controller.ts"/>
@@ -13,29 +13,22 @@ var QuickFind = /** @class */ (function () {
1313 for ( var i = 0 ; i < size ; i ++ ) {
1414 this . arr [ i ] = i ;
1515 }
16- this . pause = false ;
1716 }
1817 QuickFind . prototype . union = function ( aIndex , bIndex ) {
1918 var aRoot = this . arr [ aIndex ] ;
2019 var bRoot = this . arr [ bIndex ] ;
2120 if ( aRoot == bRoot ) {
22- this . delay ( this . getDelayTime ( ) * 2 ) ;
2321 control . setSelectedIndex ( aIndex , false ) ;
2422 control . setSelectedIndex ( bIndex , false ) ;
2523 return ;
2624 }
2725 control . saveState ( this . arr ) ;
2826 for ( var i = 0 ; i < this . arr . length ; i ++ ) {
29- while ( this . pause ) {
30- this . delay ( this . getDelayTime ( ) ) ;
31- }
3227 control . setArrow ( i ) ;
33- this . delay ( this . getDelayTime ( ) ) ;
3428 if ( this . arr [ i ] == aRoot ) {
3529 control . setValueAtIndex ( i , bRoot ) ;
3630 control . connectNodes ( i , bRoot ) ;
3731 this . arr [ i ] = bRoot ;
38- this . delay ( this . getDelayTime ( ) ) ;
3932 }
4033 }
4134 control . setArrow ( - 1 ) ;
@@ -51,30 +44,19 @@ var QuickFind = /** @class */ (function () {
5144 }
5245 else
5346 control . redCross ( aIndex , bIndex , true ) ;
54- this . delay ( this . getDelayTime ( ) ) ;
55- this . removeHighlighFromRoot ( aIndex ) ;
56- this . removeHighlighFromRoot ( bIndex ) ;
47+ control . setSelectedIndex ( bIndex , false ) ;
48+ control . removeHighlight ( this . arr [ bIndex ] ) ;
49+ control . setSelectedIndex ( aIndex , false ) ;
50+ control . removeHighlight ( this . arr [ aIndex ] ) ;
5751 control . checkMark ( aIndex , bIndex , false ) ;
5852 control . redCross ( aIndex , bIndex , false ) ;
5953 return connected ;
6054 } ;
6155 QuickFind . prototype . getName = function ( ) {
6256 return this . name ;
6357 } ;
64- QuickFind . prototype . removeHighlighFromRoot = function ( pIndex ) {
65- control . removeHighlight ( this . arr [ pIndex ] ) ;
66- } ;
67- QuickFind . prototype . delay = function ( delayTime ) {
68- /*
69- let start = new Date().getTime();
70- for (let i = 0; i < 1e7; i++) {
71- if ((new Date().getTime() - start) > delayTime)
72- break;
73- }*/
74- } ;
7558 QuickFind . prototype . find = function ( pIndex ) {
7659 var root = this . simpleFind ( pIndex , "green" ) ;
77- this . delay ( this . getDelayTime ( ) ) ;
7860 control . removeHighlight ( root ) ;
7961 control . setSelectedIndex ( pIndex , false ) ;
8062 return root ;
@@ -83,7 +65,6 @@ var QuickFind = /** @class */ (function () {
8365 var root = this . arr [ pIndex ] ;
8466 if ( pIndex != root ) {
8567 control . highlightNode ( pIndex , "orange" ) ;
86- this . delay ( this . getDelayTime ( ) ) ;
8768 control . removeHighlight ( pIndex ) ;
8869 }
8970 control . highlightNode ( root , color ) ;
@@ -95,20 +76,11 @@ var QuickFind = /** @class */ (function () {
9576 QuickFind . prototype . setArray = function ( array ) {
9677 this . arr = array ;
9778 } ;
98- QuickFind . prototype . isPause = function ( ) {
99- return this . pause ;
100- } ;
101- QuickFind . prototype . invertPause = function ( ) {
102- this . pause = ! this . pause ;
103- } ;
10479 QuickFind . prototype . connectedNoGUIUpdate = function ( a , b ) {
10580 return this . arr [ a ] == this . arr [ b ] ;
10681 } ;
10782 QuickFind . prototype . getDelayTime = function ( ) {
10883 return this . DELAY + control . getSpeed ( ) ;
10984 } ;
110- QuickFind . prototype . setController = function ( control ) {
111- //
112- } ;
11385 return QuickFind ;
11486} ( ) ) ;
0 commit comments