Skip to content

Commit

Permalink
Adjustments according to comments, shortened doc on convenience metho…
Browse files Browse the repository at this point in the history
…d, declared magic numbers in local variables;
  • Loading branch information
JonasSchaub committed May 2, 2023
1 parent 2ff5c46 commit 5aae9bf
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,10 @@ public static enum CycleFinderOption {
* Constructor, all settings are initialised with their default values as declared in the respective public constants.
*/
public ErtlFunctionalGroupsFinderFragmenter() {
int tmpInitialCapacityForSettingNameTooltipTextMap = CollectionUtil.calculateInitialHashCollectionCapacity(6, BasicDefinitions.DEFAULT_HASH_COLLECTION_LOAD_FACTOR);
int tmpNumberOfSettingsForTooltipMapSize= 6;
int tmpInitialCapacityForSettingNameTooltipTextMap = CollectionUtil.calculateInitialHashCollectionCapacity(
tmpNumberOfSettingsForTooltipMapSize,
BasicDefinitions.DEFAULT_HASH_COLLECTION_LOAD_FACTOR);
this.settingNameTooltipTextMap = new HashMap(tmpInitialCapacityForSettingNameTooltipTextMap, BasicDefinitions.DEFAULT_HASH_COLLECTION_LOAD_FACTOR);
this.fragmentSaturationSetting = new SimpleEnumConstantNameProperty(this, "Fragment saturation setting",
IMoleculeFragmenter.FRAGMENT_SATURATION_OPTION_DEFAULT.name(), IMoleculeFragmenter.FragmentSaturationOption.class) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@ public static enum FragmentationTypeOption {
*/
public ScaffoldGeneratorFragmenter() {
this.scaffoldGeneratorInstance = new ScaffoldGenerator();
int tmpInitialCapacityForSettingNameTooltipTextMap = CollectionUtil.calculateInitialHashCollectionCapacity(16, BasicDefinitions.DEFAULT_HASH_COLLECTION_LOAD_FACTOR);
int tmpNumberOfSettingsForTooltipMapSize= 10;
int tmpInitialCapacityForSettingNameTooltipTextMap = CollectionUtil.calculateInitialHashCollectionCapacity(
tmpNumberOfSettingsForTooltipMapSize,
BasicDefinitions.DEFAULT_HASH_COLLECTION_LOAD_FACTOR);
this.settingNameTooltipTextMap = new HashMap(tmpInitialCapacityForSettingNameTooltipTextMap, BasicDefinitions.DEFAULT_HASH_COLLECTION_LOAD_FACTOR);
this.fragmentSaturationSetting = new SimpleEnumConstantNameProperty(this, "Fragment saturation setting",
IMoleculeFragmenter.FRAGMENT_SATURATION_OPTION_DEFAULT.name(), IMoleculeFragmenter.FragmentSaturationOption.class) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,11 @@ public static enum SRUFragmenterReturnedFragmentsOption {
*/
public SugarRemovalUtilityFragmenter() {
this.sugarRUInstance = new SugarRemovalUtility(SilentChemObjectBuilder.getInstance());
this.settings = new ArrayList<>(15);
int tmpInitialCapacityForSettingNameTooltipTextMap = CollectionUtil.calculateInitialHashCollectionCapacity(20, BasicDefinitions.DEFAULT_HASH_COLLECTION_LOAD_FACTOR);
int tmpNumberOfSettings = 15;
this.settings = new ArrayList<>(tmpNumberOfSettings);
int tmpInitialCapacityForSettingNameTooltipTextMap = CollectionUtil.calculateInitialHashCollectionCapacity(
tmpNumberOfSettings,
BasicDefinitions.DEFAULT_HASH_COLLECTION_LOAD_FACTOR);
this.settingNameTooltipTextMap = new HashMap<>(tmpInitialCapacityForSettingNameTooltipTextMap, BasicDefinitions.DEFAULT_HASH_COLLECTION_LOAD_FACTOR);
this.returnedFragmentsSetting = new SimpleEnumConstantNameProperty(this, "Returned fragments setting",
SugarRemovalUtilityFragmenter.RETURNED_FRAGMENTS_OPTION_DEFAULT.name(), SugarRemovalUtilityFragmenter.SRUFragmenterReturnedFragmentsOption.class) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,10 @@ public void reloadGlobalSettings() {
* to the list of settings for display to the user.
*/
private void initialiseSettings() {
int tmpInitialCapacityForSettingNameTooltipTextMap = CollectionUtil.calculateInitialHashCollectionCapacity(10, BasicDefinitions.DEFAULT_HASH_COLLECTION_LOAD_FACTOR);
int tmpNumberOfSettings = 8;
int tmpInitialCapacityForSettingNameTooltipTextMap = CollectionUtil.calculateInitialHashCollectionCapacity(
tmpNumberOfSettings,
BasicDefinitions.DEFAULT_HASH_COLLECTION_LOAD_FACTOR);
this.settingNameTooltipTextMap = new HashMap<String, String>(tmpInitialCapacityForSettingNameTooltipTextMap, BasicDefinitions.DEFAULT_HASH_COLLECTION_LOAD_FACTOR);
this.rowsPerPageSetting = new SimpleIntegerProperty(this,
"Rows per page setting",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ public static void sortGivenFragmentListByPropertyAndSortType(List<MoleculeDataM
//
/**
* Calculates a suitable initial size for instantiating a new HashMap or HashSet instance based on the number of elements
* supposed to be stored in it and the load factor that determines the rehash threshold.
* supposed to be stored in it and the load factor that determines the resize threshold.
* Calculation: initCap = (int) aNumberOfElement * (1/aLoadFactor) + 2
* <br>The initial capacity multiplied with the load factor (= rehash threshold) must be higher than the number of
* <br>The initial capacity multiplied with the load factor (= resize threshold) must be higher than the number of
* elements.
*
* @param aNumberOfElements number of elements supposed to be stored in the new HashMap or HashSet instance
* @param aLoadFactor load factor that is specified for the new HashMap or HashSet instance
* @return a suitable initial size for the new HashMap or HashSet instance that leads to a rehash threshold that is slightly
* @return a suitable initial size for the new HashMap or HashSet instance that leads to a resize threshold that is slightly
* higher than the number of elements
* @throws IllegalArgumentException if the number of elements or the load factor is negative or equal to zero
* or if the load factor is greater than 1.0
Expand All @@ -137,14 +137,12 @@ public static int calculateInitialHashCollectionCapacity(int aNumberOfElements,
}
//
/**
* Calculates a suitable initial size for instantiating a new HashMap or HashSet instance based on the number of elements
* supposed to be stored in it and the default load factor (0.75) that determines the rehash threshold.
* Calculation: initCap = (int) aNumberOfElement * (1/0.75) + 2
* <br>The initial capacity multiplied with the load factor (= rehash threshold) must be higher than the number of
* elements.
* Calculates a suitable initial size for instantiating a new HashMap or HashSet instance with the default load factor.
* <br>For more details, see {@link #calculateInitialHashCollectionCapacity(int, float) calculateInitialHashCollectionCapacity(int, float)}.
*
*
* @param aNumberOfElements number of elements supposed to be stored in the new HashMap or HashSet instance
* @return a suitable initial size for the new HashMap or HashSet instance that leads to a rehash threshold that is slightly
* @return a suitable initial size for the new HashMap or HashSet instance that leads to a resize threshold that is slightly
* higher than the number of elements
* @throws IllegalArgumentException if the number of elements is negative or equal to zero
*/
Expand Down

0 comments on commit 5aae9bf

Please sign in to comment.