diff options
| author | miozune <miozune@gmail.com> | 2023-05-17 00:01:01 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-16 17:01:01 +0200 |
| commit | 04514282c08ebefdb3e68a46db34092f72be2316 (patch) | |
| tree | 0c9bc99f480f7e7f45a99a55a5b6619ebb5b014b /src/main/java/gtPlusPlus/api | |
| parent | cd58ff7cd4dc4b5ffe917a24a4b4c6da577f462d (diff) | |
| download | GT5-Unofficial-04514282c08ebefdb3e68a46db34092f72be2316.tar.gz GT5-Unofficial-04514282c08ebefdb3e68a46db34092f72be2316.tar.bz2 GT5-Unofficial-04514282c08ebefdb3e68a46db34092f72be2316.zip | |
Remove a lot of unused classes (#629)
Diffstat (limited to 'src/main/java/gtPlusPlus/api')
29 files changed, 0 insertions, 2367 deletions
diff --git a/src/main/java/gtPlusPlus/api/enums/ParticleNames.java b/src/main/java/gtPlusPlus/api/enums/ParticleNames.java deleted file mode 100644 index 335442dbc7..0000000000 --- a/src/main/java/gtPlusPlus/api/enums/ParticleNames.java +++ /dev/null @@ -1,35 +0,0 @@ -package gtPlusPlus.api.enums; - -public enum ParticleNames { - explode, - largeexplode, - hugeexplosion, - bubble, - splash, - suspended, - depthsuspend, - crit, - magicCrit, - smoke, - largesmoke, - spell, - instantSpell, - mobSpell, - dripWater, - dripLava, - townaura, - note, - portal, - enchantmenttable, - flame, - lava, - footstep, - cloud, - reddust, - snowballpoof, - snowshovel, - slime, - heart, - iconcrack_, - tilecrack_; -} diff --git a/src/main/java/gtPlusPlus/api/enums/Quality.java b/src/main/java/gtPlusPlus/api/enums/Quality.java deleted file mode 100644 index efcf2a015f..0000000000 --- a/src/main/java/gtPlusPlus/api/enums/Quality.java +++ /dev/null @@ -1,66 +0,0 @@ -package gtPlusPlus.api.enums; - -import net.minecraft.util.EnumChatFormatting; - -import gtPlusPlus.core.util.math.MathUtils; - -public enum Quality { - - // Magic Blue - // Rare Yellow - // Set Green - // Unique Gold/Purple - // Trade-off Brown - - POOR("Poor", EnumChatFormatting.GRAY), - COMMON("Common", EnumChatFormatting.WHITE), - UNCOMMON("Uncommon", EnumChatFormatting.DARK_GREEN), - MAGIC("Magic", EnumChatFormatting.BLUE), - RARE("Rare", EnumChatFormatting.YELLOW), - UNIQUE("Unique", EnumChatFormatting.GOLD), - ARTIFACT("Artifact", EnumChatFormatting.AQUA), - SET("Set Piece", EnumChatFormatting.GREEN), - TRADEOFF("Trade-off", EnumChatFormatting.DARK_RED), - EPIC("Epic", EnumChatFormatting.LIGHT_PURPLE); - - private String LOOT; - private EnumChatFormatting COLOUR; - - private Quality(final String lootTier, final EnumChatFormatting tooltipColour) { - this.LOOT = lootTier; - this.COLOUR = tooltipColour; - } - - public String getQuality() { - return this.LOOT; - } - - protected EnumChatFormatting getColour() { - return this.COLOUR; - } - - public String formatted() { - return this.COLOUR + this.LOOT; - } - - public static Quality getRandomQuality() { - final int lootChance = MathUtils.randInt(0, 100); - if (lootChance <= 10) { - return Quality.POOR; - } else if (lootChance <= 45) { - return Quality.COMMON; - } else if (lootChance <= 65) { - return Quality.UNCOMMON; - } else if (lootChance <= 82) { - return Quality.MAGIC; - } else if (lootChance <= 92) { - return Quality.EPIC; - } else if (lootChance <= 97) { - return Quality.RARE; - } else if (lootChance <= 99) { - return Quality.ARTIFACT; - } else { - return null; - } - } -} diff --git a/src/main/java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java b/src/main/java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java index a85bd42213..24d2da3134 100644 --- a/src/main/java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java +++ b/src/main/java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java @@ -2,26 +2,13 @@ package gtPlusPlus.api.helpers; import java.util.HashMap; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.WeightedCollection; import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy_RTG; import gtPlusPlus.xmod.gregtech.api.util.SpecialBehaviourTooltipHandler; public class GregtechPlusPlus_API { - public static class MolecularTransformer_API { - - public static boolean addRecipe(ItemStack aInput, ItemStack aOutput, int aDuration, int aEU) { - return CORE.RA.addMolecularTransformerRecipe(aInput, aOutput, aDuration, aEU, 1); - } - } - public static class Multiblock_API { private static final HashMap<String, SpecialMultiBehaviour> mSpecialBehaviourItemMap = new HashMap<String, SpecialMultiBehaviour>(); @@ -50,166 +37,5 @@ public class GregtechPlusPlus_API { public static final HashMap<String, SpecialMultiBehaviour> getSpecialBehaviourItemMap() { return mSpecialBehaviourItemMap; } - - /** - * Allows RTG Fuel pellets from other mods to be used in the RTG hatch. - * - * @param aStack - The Pellet Stack, sanitsed after passing through. - * @param aFuelValue - The Fuel Value of the Pellet to be added to the energy storage. - * @return - Did register? - */ - public static boolean registerPelletForRtgHatch(ItemStack aStack, long aFuelValue) { - return GT_MetaTileEntity_Hatch_Energy_RTG.registerPelletForHatch(aStack, aFuelValue); - } - } - - public static class VoidMiner_API { - - private static final HashMap<Integer, HashMap<String, WeightedCollection<Block>>> mMinerLootCache; - - static { - mMinerLootCache = new HashMap<Integer, HashMap<String, WeightedCollection<Block>>>(); - } - - /** - * - * Registers an ore block for a dimension. Uses a default weight of 100. - * - * @param aDim - The Dimension ID - * @param aOredictName - The OreDict name of the Ore to be mined. - * @return - If there was a valid Block found in the OreDict for the provided name. - */ - public static boolean registerOreForVoidMiner(int aDim, String aOredictName) { - return registerOreForVoidMiner(aDim, aOredictName, 100); - } - - /** - * - * Registers an ore block for a dimension. Uses a default weight of 100. - * - * @param aDim - The Dimension ID - * @param aOredictName - The OreDict name of the Ore to be mined. - * @param aWeight - The weight of this ore Block. - * @return - If there was a valid Block found in the OreDict for the provided name. - */ - public static boolean registerOreForVoidMiner(int aDim, String aOredictName, int aWeight) { - Block b = null; - ItemStack[] aValidItems = ItemUtils.validItemsForOreDict(aOredictName); - for (ItemStack g : aValidItems) { - if (g != null) { - b = Block.getBlockFromItem(g.getItem()); - if (b != null) { - break; - } - } - } - if (b != null) { - registerOreForVoidMiner(aDim, b, aWeight); - return true; - } - return false; - } - - /** - * Registers an ore block for a dimension. Uses a default weight of 100. - * - * @param aDim - The Dimension ID - * @param aOreBlock - The Ore Block to be mined. - */ - public static void registerOreForVoidMiner(int aDim, Block aOreBlock) { - registerOreForVoidMiner(aDim, aOreBlock, 100); - } - - /** - * Registers an ore block for a dimension. - * - * @param aDim - The Dimension ID - * @param aOreBlock - The Ore Block to be mined. - * @param aWeight - The weight of this ore Block. - */ - public static void registerOreForVoidMiner(int aDim, Block aOreBlock, int aWeight) { - GregtechPlusPlus_API_Internal.writeBlockToDimensionInCache(aDim, 0, aOreBlock, aWeight); - } - - /** - * Registers a surface block for a dimension. Uses a default weight of 100. - * - * @param aDim - The Dimension ID - * @param aDirtBlock - The Dirt/Grass Block to be mined. - */ - public static void registerEarthSurfaceForVoidMiner(int aDim, Block aDirtBlock) { - registerEarthSurfaceForVoidMiner(aDim, aDirtBlock, 100); - } - - /** - * Registers a surface block for a dimension. - * - * @param aDim - The Dimension ID - * @param aDirtBlock - The Dirt/Grass Block to be mined. - * @param aWeight - The weight of this Dirt/Grass Block. - */ - public static void registerEarthSurfaceForVoidMiner(int aDim, Block aDirtBlock, int aWeight) { - GregtechPlusPlus_API_Internal.writeBlockToDimensionInCache(aDim, 0, aDirtBlock, aWeight); - } - - /** - * Registers a stone block for a dimension. Uses a default weight of 100. - * - * @param aDim - The Dimension ID - * @param aStoneBlock - The Stone Block to be mined. - */ - public static void registerEarthStoneForVoidMiner(int aDim, Block aStoneBlock) { - registerEarthStoneForVoidMiner(aDim, aStoneBlock, 100); - } - - /** - * Registers a stone block for a dimension. - * - * @param aDim - The Dimension ID - * @param aStoneBlock - The Stone Block to be mined. - * @param aWeight - The weight of this Stone Block. - */ - public static void registerEarthStoneForVoidMiner(int aDim, Block aStoneBlock, int aWeight) { - GregtechPlusPlus_API_Internal.writeBlockToDimensionInCache(aDim, 0, aStoneBlock, aWeight); - } - - public static WeightedCollection<Block> getAllRegisteredOresForDimension(int aDim) { - return mMinerLootCache.get(aDim).get("ore"); - } - - public static WeightedCollection<Block> getAllRegisteredDirtTypesForDimension(int aDim) { - return mMinerLootCache.get(aDim).get("dirt"); - } - - public static WeightedCollection<Block> getAllRegisteredStoneTypesForDimension(int aDim) { - return mMinerLootCache.get(aDim).get("stone"); - } - - public static final HashMap<Integer, HashMap<String, WeightedCollection<Block>>> getVoidMinerLootCache() { - return mMinerLootCache; - } - } - - private static class GregtechPlusPlus_API_Internal { - - private static void writeBlockToDimensionInCache(int aDim, int aType, Block aBlock, int aWeight) { - HashMap<String, WeightedCollection<Block>> aDimMap = VoidMiner_API.mMinerLootCache.get(aDim); - if (aDimMap == null) { - aDimMap = new HashMap<String, WeightedCollection<Block>>(); - } - WeightedCollection<Block> aMappedBlocks = getBlockMap(aType, aDimMap); - aMappedBlocks.put(aWeight, aBlock); - } - - private static WeightedCollection<Block> getBlockMap(int aType, - HashMap<String, WeightedCollection<Block>> aDimMap) { - WeightedCollection<Block> aMappedBlocks; - String aTypeName = ((aType == 0) ? "ore" : (aType == 1) ? "dirt" : (aType == 2) ? "stone" : "error"); - aMappedBlocks = aDimMap.get(aTypeName); - if (aMappedBlocks == null) { - aMappedBlocks = new WeightedCollection<Block>(); - } - return aMappedBlocks; - } } } diff --git a/src/main/java/gtPlusPlus/api/interfaces/IChunkLoader.java b/src/main/java/gtPlusPlus/api/interfaces/IChunkLoader.java deleted file mode 100644 index cec4d12716..0000000000 --- a/src/main/java/gtPlusPlus/api/interfaces/IChunkLoader.java +++ /dev/null @@ -1,32 +0,0 @@ -package gtPlusPlus.api.interfaces; - -import java.util.Set; - -import net.minecraft.world.ChunkCoordIntPair; - -public interface IChunkLoader { - - public long getTicksRemaining(); - - public void setTicksRemaining(long aTicks); - - public ChunkCoordIntPair getResidingChunk(); - - public void setResidingChunk(ChunkCoordIntPair aCurrentChunk); - - public boolean getChunkLoadingActive(); - - public void setChunkLoadingActive(boolean aActive); - - public boolean getDoesWorkChunkNeedReload(); - - public void setDoesWorkChunkNeedReload(boolean aActive); - - public boolean addChunkToLoadedList(ChunkCoordIntPair aActiveChunk); - - public boolean removeChunkFromLoadedList(ChunkCoordIntPair aActiveChunk); - - public Set<ChunkCoordIntPair> getManagedChunks(); - - public int getChunkloaderTier(); -} diff --git a/src/main/java/gtPlusPlus/api/interfaces/IComparableRecipe.java b/src/main/java/gtPlusPlus/api/interfaces/IComparableRecipe.java deleted file mode 100644 index 06727167bf..0000000000 --- a/src/main/java/gtPlusPlus/api/interfaces/IComparableRecipe.java +++ /dev/null @@ -1,6 +0,0 @@ -package gtPlusPlus.api.interfaces; - -import gregtech.api.util.GT_Recipe; - -public interface IComparableRecipe extends Comparable<GT_Recipe> { -} diff --git a/src/main/java/gtPlusPlus/api/interfaces/IGeneratorWorld.java b/src/main/java/gtPlusPlus/api/interfaces/IGeneratorWorld.java deleted file mode 100644 index 95cd46e443..0000000000 --- a/src/main/java/gtPlusPlus/api/interfaces/IGeneratorWorld.java +++ /dev/null @@ -1,18 +0,0 @@ -package gtPlusPlus.api.interfaces; - -import java.util.Random; - -import net.minecraft.world.World; - -public abstract interface IGeneratorWorld { - - public abstract boolean generate(World paramWorld, Random paramRandom, int paramInt1, int paramInt2); - - public abstract void initiate(); - - public abstract int getExtentX(); - - public abstract int getExtentZ(); - - public abstract int getRange(); -} diff --git a/src/main/java/gtPlusPlus/api/interfaces/IGregtechPacketEntity.java b/src/main/java/gtPlusPlus/api/interfaces/IGregtechPacketEntity.java deleted file mode 100644 index 4a41e47a7b..0000000000 --- a/src/main/java/gtPlusPlus/api/interfaces/IGregtechPacketEntity.java +++ /dev/null @@ -1,12 +0,0 @@ -package gtPlusPlus.api.interfaces; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -public interface IGregtechPacketEntity { - - public void writePacketData(DataOutputStream data) throws IOException; - - public void readPacketData(DataInputStream data) throws IOException; -} diff --git a/src/main/java/gtPlusPlus/api/interfaces/IGregtechPower.java b/src/main/java/gtPlusPlus/api/interfaces/IGregtechPower.java deleted file mode 100644 index f121926005..0000000000 --- a/src/main/java/gtPlusPlus/api/interfaces/IGregtechPower.java +++ /dev/null @@ -1,142 +0,0 @@ -package gtPlusPlus.api.interfaces; - -import net.minecraft.block.Block; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.interfaces.IDescribable; -import gregtech.api.interfaces.tileentity.IBasicEnergyContainer; -import gregtech.api.interfaces.tileentity.IGearEnergyTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechDeviceInformation; -import gregtech.api.interfaces.tileentity.ITurnable; - -public abstract interface IGregtechPower - extends IGearEnergyTileEntity, ITurnable, IGregTechDeviceInformation, IDescribable, IBasicEnergyContainer { - - @Override - public String[] getDescription(); - - @Override - default boolean isUniversalEnergyStored(long p0) { - return false; - } - - @Override - public long getOutputAmperage(); - - @Override - public long getOutputVoltage(); - - @Override - public long getInputAmperage(); - - @Override - public long getInputVoltage(); - - @Override - public boolean decreaseStoredEnergyUnits(long p0, boolean p1); - - @Override - public boolean increaseStoredEnergyUnits(long p0, boolean p1); - - @Override - public boolean drainEnergyUnits(ForgeDirection side, long p1, long p2); - - @Override - public long getAverageElectricInput(); - - @Override - public long getAverageElectricOutput(); - - @Override - public long getStoredEU(); - - @Override - public long getEUCapacity(); - - @Override - public long getStoredSteam(); - - @Override - public long getSteamCapacity(); - - @Override - public boolean increaseStoredSteam(long p0, boolean p1); - - @Override - public Block getBlockAtSide(ForgeDirection side); - - @Override - public Block getBlockAtSideAndDistance(ForgeDirection side, int p1); - - @Override - public Block getBlockOffset(int p0, int p1, int p2); - - @Override - public TileEntity getTileEntity(int p0, int p1, int p2); - - @Override - public TileEntity getTileEntityAtSide(ForgeDirection side); - - @Override - public TileEntity getTileEntityAtSideAndDistance(ForgeDirection side, int p1); - - @Override - public TileEntity getTileEntityOffset(int p0, int p1, int p2); - - @Override - public World getWorld(); - - @Override - public int getXCoord(); - - @Override - public short getYCoord(); - - @Override - public int getZCoord(); - - @Override - public boolean isClientSide(); - - @Override - public boolean isDead(); - - @Override - public boolean isInvalidTileEntity(); - - @Override - public boolean isServerSide(); - - @Override - public void readFromNBT(NBTTagCompound p0); - - @Override - public void writeToNBT(NBTTagCompound p0); - - @Override - public boolean acceptsRotationalEnergy(ForgeDirection side); - - @Override - public boolean injectRotationalEnergy(ForgeDirection side, long p1, long p2); - - @Override - public long injectEnergyUnits(ForgeDirection side, long p1, long p2); - - @Override - public boolean inputEnergyFrom(ForgeDirection side); - - @Override - public boolean outputsEnergyTo(ForgeDirection side); - - @Override - public String[] getInfoData(); - - @Override - public default boolean isGivingInformation() { - return true; - } - -} diff --git a/src/main/java/gtPlusPlus/api/interfaces/IRandomGenerator.java b/src/main/java/gtPlusPlus/api/interfaces/IRandomGenerator.java deleted file mode 100644 index ddb4d4d2f1..0000000000 --- a/src/main/java/gtPlusPlus/api/interfaces/IRandomGenerator.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2005, Nick Galbreath -- nickg [at] modp [dot] com All rights reserved. Redistribution and use in source and - * binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following - * disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the - * following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of - * the modp.com nor the names of its contributors may be used to endorse or promote products derived from this software - * without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. This is the standard "new" BSD license: - * http://www.opensource.org/licenses/bsd-license.php - */ - -package gtPlusPlus.api.interfaces; - -/** - * Simplified interface for random number generation - * - * @author Nick Galbreath -- nickg [at] modp [dot] com - * @version 1 -- 06-Jul-2005 - */ -public interface IRandomGenerator { - - /** - * Returns N random bits - * - * See also java.util.Random#next - * - * @param numBits - * @return and int with the LSB being random - */ - public int next(int numBits); -} diff --git a/src/main/java/gtPlusPlus/api/objects/data/ObjMap.java b/src/main/java/gtPlusPlus/api/objects/data/ObjMap.java deleted file mode 100644 index eff314f9ae..0000000000 --- a/src/main/java/gtPlusPlus/api/objects/data/ObjMap.java +++ /dev/null @@ -1,243 +0,0 @@ -package gtPlusPlus.api.objects.data; - -import java.util.Arrays; - -/** - * Object-2-object map based on IntIntMap4a - */ -public class ObjMap<K, V> { - - private static final Object FREE_KEY = new Object(); - private static final Object REMOVED_KEY = new Object(); - - /** Keys and values */ - private Object[] m_data; - - /** Value for the null key (if inserted into a map) */ - private Object m_nullValue; - - private boolean m_hasNull; - - /** Fill factor, must be between (0 and 1) */ - private final float m_fillFactor; - /** We will resize a map once it reaches this size */ - private int m_threshold; - /** Current map size */ - private int m_size; - /** Mask to calculate the original position */ - private int m_mask; - /** Mask to wrap the actual array pointer */ - private int m_mask2; - - public ObjMap(final int size, final float fillFactor) { - if (fillFactor <= 0 || fillFactor >= 1) throw new IllegalArgumentException("FillFactor must be in (0, 1)"); - if (size <= 0) throw new IllegalArgumentException("Size must be positive!"); - final int capacity = arraySize(size, fillFactor); - m_mask = capacity - 1; - m_mask2 = capacity * 2 - 1; - m_fillFactor = fillFactor; - - m_data = new Object[capacity * 2]; - Arrays.fill(m_data, FREE_KEY); - - m_threshold = (int) (capacity * fillFactor); - } - - @SuppressWarnings("unchecked") - public V get(final K key) { - if (key == null) return (V) m_nullValue; // we null it on remove, so safe not to check a flag here - - int ptr = (key.hashCode() & m_mask) << 1; - Object k = m_data[ptr]; - - if (k == FREE_KEY) return null; // end of chain already - if (k.equals(key)) // we check FREE and REMOVED prior to this call - return (V) m_data[ptr + 1]; - while (true) { - ptr = (ptr + 2) & m_mask2; // that's next index - k = m_data[ptr]; - if (k == FREE_KEY) return null; - if (k.equals(key)) return (V) m_data[ptr + 1]; - } - } - - @SuppressWarnings("unchecked") - public V put(final K key, final V value) { - if (key == null) return insertNullKey(value); - - int ptr = getStartIndex(key) << 1; - Object k = m_data[ptr]; - - if (k == FREE_KEY) // end of chain already - { - m_data[ptr] = key; - m_data[ptr + 1] = value; - if (m_size >= m_threshold) rehash(m_data.length * 2); // size is set inside - else++m_size; - return null; - } else if (k.equals(key)) // we check FREE and REMOVED prior to this call - { - final Object ret = m_data[ptr + 1]; - m_data[ptr + 1] = value; - return (V) ret; - } - - int firstRemoved = -1; - if (k == REMOVED_KEY) firstRemoved = ptr; // we may find a key later - - while (true) { - ptr = (ptr + 2) & m_mask2; // that's next index calculation - k = m_data[ptr]; - if (k == FREE_KEY) { - if (firstRemoved != -1) ptr = firstRemoved; - m_data[ptr] = key; - m_data[ptr + 1] = value; - if (m_size >= m_threshold) rehash(m_data.length * 2); // size is set inside - else++m_size; - return null; - } else if (k.equals(key)) { - final Object ret = m_data[ptr + 1]; - m_data[ptr + 1] = value; - return (V) ret; - } else if (k == REMOVED_KEY) { - if (firstRemoved == -1) firstRemoved = ptr; - } - } - } - - @SuppressWarnings("unchecked") - public V remove(final K key) { - if (key == null) return removeNullKey(); - - int ptr = getStartIndex(key) << 1; - Object k = m_data[ptr]; - if (k == FREE_KEY) return null; // end of chain already - else if (k.equals(key)) // we check FREE and REMOVED prior to this call - { - --m_size; - if (m_data[(ptr + 2) & m_mask2] == FREE_KEY) m_data[ptr] = FREE_KEY; - else m_data[ptr] = REMOVED_KEY; - final V ret = (V) m_data[ptr + 1]; - m_data[ptr + 1] = null; - return ret; - } - while (true) { - ptr = (ptr + 2) & m_mask2; // that's next index calculation - k = m_data[ptr]; - if (k == FREE_KEY) return null; - else if (k.equals(key)) { - --m_size; - if (m_data[(ptr + 2) & m_mask2] == FREE_KEY) m_data[ptr] = FREE_KEY; - else m_data[ptr] = REMOVED_KEY; - final V ret = (V) m_data[ptr + 1]; - m_data[ptr + 1] = null; - return ret; - } - } - } - - @SuppressWarnings("unchecked") - private V insertNullKey(final V value) { - if (m_hasNull) { - final Object ret = m_nullValue; - m_nullValue = value; - return (V) ret; - } else { - m_nullValue = value; - ++m_size; - return null; - } < |
