-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1000 from johnbrvc/i999_execute_grace_period
Two approvals. Code has low impact on the system. Tested with multiple contests.
- Loading branch information
Showing
11 changed files
with
449 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/edu/csus/ecs/pc2/core/list/AlphaNumericComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. | ||
package edu.csus.ecs.pc2.core.list; | ||
|
||
import java.io.Serializable; | ||
import java.util.Comparator; | ||
|
||
/** | ||
* Compare the two strings as numbers | ||
* <P> | ||
* Compare things that may be words or numbers | ||
* | ||
* @author John Buck | ||
*/ | ||
|
||
// $HeadURL$ | ||
// $Id$ | ||
|
||
public class AlphaNumericComparator implements Comparator<String>, Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public int compare(String ValOne, String ValTwo) { | ||
boolean b1Alpha = false; | ||
boolean b2Alpha = false; | ||
int cmpVal1 = 0; | ||
int cmpVal2 = 0; | ||
|
||
try { | ||
cmpVal1 = Integer.parseInt(ValOne); | ||
} catch(Exception exception) { | ||
b1Alpha = true; | ||
} | ||
try { | ||
cmpVal2 = Integer.parseInt(ValTwo); | ||
} catch(Exception exception) { | ||
b2Alpha = true; | ||
} | ||
if(b1Alpha) { | ||
// If both are alpha, then just compare the strings. | ||
if(b2Alpha) { | ||
return(ValOne.compareToIgnoreCase(ValTwo)); | ||
} | ||
// ValTwo is a number, and it comes before the alpha | ||
return(1); | ||
} | ||
if(b2Alpha) { | ||
// ValOne is a number, it comes before the alpha string | ||
return(-1); | ||
} | ||
return(cmpVal1 - cmpVal2); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/edu/csus/ecs/pc2/core/list/LabelToDoubleComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (C) 1989-2024 PC2 Development Team: John Clevenger, Douglas Lane, Samir Ashoo, and Troy Boudreau. | ||
package edu.csus.ecs.pc2.core.list; | ||
|
||
import java.io.Serializable; | ||
import java.util.Comparator; | ||
|
||
import javax.swing.JLabel; | ||
|
||
/** | ||
* Compare the two strings as numbers | ||
* <P> | ||
* Simply convert to integers and compare | ||
* | ||
* @version $Id$ | ||
* @author John Buck | ||
*/ | ||
|
||
// $HeadURL$ | ||
// $Id$ | ||
|
||
public class LabelToDoubleComparator implements Comparator<JLabel>, Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public int compare(JLabel LabOne, JLabel LabTwo) { | ||
String valOne = LabOne.getText(); | ||
String valTwo = LabTwo.getText(); | ||
boolean b1Alpha = false; | ||
boolean b2Alpha = false; | ||
double cmpVal1 = 0; | ||
double cmpVal2 = 0; | ||
|
||
try { | ||
cmpVal1 = Double.parseDouble(valOne); | ||
} catch(Exception exception) { | ||
b1Alpha = true; | ||
} | ||
try { | ||
cmpVal2 = Double.parseDouble(valTwo); | ||
} catch(Exception exception) { | ||
b2Alpha = true; | ||
} | ||
if(b1Alpha) { | ||
// If both are alpha, then just compare the strings. | ||
if(b2Alpha) { | ||
return(valOne.compareToIgnoreCase(valTwo)); | ||
} | ||
// ValTwo is a number, and it comes before the alpha | ||
return(1); | ||
} | ||
if(b2Alpha) { | ||
// ValOne is a number, it comes before the alpha string | ||
return(-1); | ||
} | ||
double dResult = cmpVal1 - cmpVal2; | ||
if(dResult < 0) { | ||
return(-1); | ||
} else if(dResult > 0) { | ||
return(1); | ||
} | ||
return(0); | ||
} | ||
} |
38 changes: 0 additions & 38 deletions
38
src/edu/csus/ecs/pc2/core/list/StringToDoubleComparator.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.