java.lang.Integer.reverse()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(168)

本文整理了Java中java.lang.Integer.reverse()方法的一些代码示例,展示了Integer.reverse()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Integer.reverse()方法的具体详情如下:
包路径:java.lang.Integer
类名称:Integer
方法名:reverse

Integer.reverse介绍

[英]Reverses the order of the bits of the specified integer.
[中]反转指定整数位的顺序。

代码示例

代码示例来源:origin: stackoverflow.com

  1. byte bitsRev = (byte) (Integer.reverse(aByte) >>> (Integer.SIZE - Byte.SIZE));

代码示例来源:origin: com.h2database/h2

  1. @Override
  2. public Object read(ByteBuffer buff, int tag) {
  3. switch (tag) {
  4. case TAG_FLOAT_0:
  5. return 0f;
  6. case TAG_FLOAT_1:
  7. return 1f;
  8. case TAG_FLOAT_FIXED:
  9. return buff.getFloat();
  10. }
  11. return Float.intBitsToFloat(Integer.reverse(DataUtils
  12. .readVarInt(buff)));
  13. }

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(short element, int removedIndex)
  2. {
  3. int nextIndex = Integer.reverse(SpreadFunctions.shortSpreadOne(element));
  4. int spreadTwo = Integer.reverse(SpreadFunctions.shortSpreadTwo(element)) | 1;
  5. while(true)
  6. {
  7. nextIndex = this.mask(nextIndex + spreadTwo);
  8. short keyAtIndex = this.keys[nextIndex];
  9. if (keyAtIndex == element)
  10. {
  11. return nextIndex;
  12. }
  13. if (keyAtIndex == EMPTY_KEY)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (keyAtIndex == REMOVED_KEY && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(int element, int removedIndex)
  2. {
  3. int nextIndex = Integer.reverse(SpreadFunctions.intSpreadOne(element));
  4. int spreadTwo = Integer.reverse(SpreadFunctions.intSpreadTwo(element)) | 1;
  5. while(true)
  6. {
  7. nextIndex = this.mask(nextIndex + spreadTwo);
  8. int valueAtIndex = this.table[nextIndex];
  9. if (valueAtIndex == element)
  10. {
  11. return nextIndex;
  12. }
  13. if (valueAtIndex == EMPTY)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (valueAtIndex == REMOVED && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(int element, int removedIndex)
  2. {
  3. int nextIndex = Integer.reverse(SpreadFunctions.intSpreadOne(element));
  4. int spreadTwo = Integer.reverse(SpreadFunctions.intSpreadTwo(element)) | 1;
  5. while(true)
  6. {
  7. nextIndex = this.mask(nextIndex + spreadTwo);
  8. int valueAtIndex = this.table[nextIndex];
  9. if (valueAtIndex == element)
  10. {
  11. return nextIndex;
  12. }
  13. if (valueAtIndex == EMPTY)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (valueAtIndex == REMOVED && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(short element, int removedIndex)
  2. {
  3. int nextIndex = Integer.reverse(SpreadFunctions.shortSpreadOne(element));
  4. int spreadTwo = Integer.reverse(SpreadFunctions.shortSpreadTwo(element)) | 1;
  5. while(true)
  6. {
  7. nextIndex = this.mask(nextIndex + spreadTwo);
  8. short valueAtIndex = this.table[nextIndex];
  9. if (valueAtIndex == element)
  10. {
  11. return nextIndex;
  12. }
  13. if (valueAtIndex == EMPTY)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (valueAtIndex == REMOVED && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(float element, int removedIndex)
  2. {
  3. int nextIndex = (int) SpreadFunctions.floatSpreadOne(element);
  4. int spreadTwo = Integer.reverse(SpreadFunctions.floatSpreadTwo(element)) | 1;
  5. while (true)
  6. {
  7. nextIndex = this.mask(nextIndex + spreadTwo);
  8. float keyAtIndex = this.keys[nextIndex];
  9. if (Float.compare(keyAtIndex, element) == 0)
  10. {
  11. return nextIndex;
  12. }
  13. if (Float.compare(keyAtIndex, EMPTY_KEY) == 0)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (Float.compare(keyAtIndex, REMOVED_KEY) == 0 && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(float element, int removedIndex)
  2. {
  3. int nextIndex = (int) SpreadFunctions.floatSpreadOne(element);
  4. int spreadTwo = Integer.reverse(SpreadFunctions.floatSpreadTwo(element)) | 1;
  5. while (true)
  6. {
  7. nextIndex = this.mask(nextIndex + spreadTwo);
  8. float keyAtIndex = this.keys[nextIndex];
  9. if (Float.compare(keyAtIndex, element) == 0)
  10. {
  11. return nextIndex;
  12. }
  13. if (Float.compare(keyAtIndex, EMPTY_KEY) == 0)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (Float.compare(keyAtIndex, REMOVED_KEY) == 0 && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(float element, int removedIndex)
  2. {
  3. int nextIndex = (int) SpreadFunctions.floatSpreadOne(element);
  4. int spreadTwo = Integer.reverse(SpreadFunctions.floatSpreadTwo(element)) | 1;
  5. while (true)
  6. {
  7. nextIndex = this.mask(nextIndex + spreadTwo);
  8. float keyAtIndex = this.keys[nextIndex];
  9. if (Float.compare(keyAtIndex, element) == 0)
  10. {
  11. return nextIndex;
  12. }
  13. if (Float.compare(keyAtIndex, EMPTY_KEY) == 0)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (Float.compare(keyAtIndex, REMOVED_KEY) == 0 && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: lealone/Lealone

  1. @Override
  2. public Value readValue(ByteBuffer buff, int tag) {
  3. switch (tag) {
  4. case TAG_FLOAT_0:
  5. return ValueFloat.get(0f);
  6. case TAG_FLOAT_1:
  7. return ValueFloat.get(1f);
  8. case TAG_FLOAT_FIXED:
  9. return ValueFloat.get(buff.getFloat());
  10. }
  11. return ValueFloat.get(Float.intBitsToFloat(Integer.reverse(DataUtils.readVarInt(buff))));
  12. }
  13. };

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(int element, int removedIndex)
  2. {
  3. int nextIndex = (int) SpreadFunctions.intSpreadOne(element);
  4. int spreadTwo = Integer.reverse(SpreadFunctions.intSpreadTwo(element)) | 1;
  5. while (true)
  6. {
  7. nextIndex = this.mask(nextIndex + spreadTwo);
  8. int keyAtIndex = this.keys[nextIndex];
  9. if (keyAtIndex == element)
  10. {
  11. return nextIndex;
  12. }
  13. if (keyAtIndex == EMPTY_KEY)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (keyAtIndex == REMOVED_KEY && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(char element, int removedIndex)
  2. {
  3. int nextIndex = (int) SpreadFunctions.charSpreadOne(element);
  4. int spreadTwo = Integer.reverse(SpreadFunctions.charSpreadTwo(element)) | 1;
  5. while (true)
  6. {
  7. nextIndex = this.mask(nextIndex + spreadTwo);
  8. char keyAtIndex = this.keys[nextIndex];
  9. if (keyAtIndex == element)
  10. {
  11. return nextIndex;
  12. }
  13. if (keyAtIndex == EMPTY_KEY)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (keyAtIndex == REMOVED_KEY && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(short element, int removedIndex)
  2. {
  3. int nextIndex = (int) SpreadFunctions.shortSpreadOne(element);
  4. int spreadTwo = Integer.reverse(SpreadFunctions.shortSpreadTwo(element)) | 1;
  5. while(true)
  6. {
  7. nextIndex = this.mask(nextIndex + spreadTwo);
  8. short keyAtIndex = this.keys[nextIndex];
  9. if (keyAtIndex == element)
  10. {
  11. return nextIndex;
  12. }
  13. if (keyAtIndex == EMPTY_KEY)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (keyAtIndex == REMOVED_KEY && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(short element, int removedIndex)
  2. {
  3. int nextIndex = (int) SpreadFunctions.shortSpreadOne(element) << 1;
  4. int spreadTwo = Integer.reverse(SpreadFunctions.shortSpreadTwo(element)) | 1;
  5. while (true)
  6. {
  7. nextIndex = this.mask((nextIndex >> 1) + spreadTwo) << 1;
  8. short keyAtIndex = this.keysValues[nextIndex];
  9. if (keyAtIndex == element)
  10. {
  11. return nextIndex;
  12. }
  13. if (keyAtIndex == EMPTY_KEY)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (keyAtIndex == REMOVED_KEY && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(char element, int removedIndex)
  2. {
  3. int nextIndex = (int) SpreadFunctions.charSpreadOne(element);
  4. int spreadTwo = Integer.reverse(SpreadFunctions.charSpreadTwo(element)) | 1;
  5. while(true)
  6. {
  7. nextIndex = this.mask(nextIndex + spreadTwo);
  8. char keyAtIndex = this.keys[nextIndex];
  9. if (keyAtIndex == element)
  10. {
  11. return nextIndex;
  12. }
  13. if (keyAtIndex == EMPTY_KEY)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (keyAtIndex == REMOVED_KEY && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(short element, int removedIndex)
  2. {
  3. int nextIndex = (int) SpreadFunctions.shortSpreadOne(element);
  4. int spreadTwo = Integer.reverse(SpreadFunctions.shortSpreadTwo(element)) | 1;
  5. while (true)
  6. {
  7. nextIndex = this.mask(nextIndex + spreadTwo);
  8. short keyAtIndex = this.keys[nextIndex];
  9. if (keyAtIndex == element)
  10. {
  11. return nextIndex;
  12. }
  13. if (keyAtIndex == EMPTY_KEY)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (keyAtIndex == REMOVED_KEY && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(char element, int removedIndex)
  2. {
  3. int nextIndex = (int) SpreadFunctions.charSpreadOne(element);
  4. int spreadTwo = Integer.reverse(SpreadFunctions.charSpreadTwo(element)) | 1;
  5. while (true)
  6. {
  7. nextIndex = this.mask(nextIndex + spreadTwo);
  8. char keyAtIndex = this.keys[nextIndex];
  9. if (keyAtIndex == element)
  10. {
  11. return nextIndex;
  12. }
  13. if (keyAtIndex == EMPTY_KEY)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (keyAtIndex == REMOVED_KEY && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: goldmansachs/gs-collections

  1. int probeThree(short element, int removedIndex)
  2. {
  3. int nextIndex = (int) SpreadFunctions.shortSpreadOne(element);
  4. int spreadTwo = Integer.reverse(SpreadFunctions.shortSpreadTwo(element)) | 1;
  5. while (true)
  6. {
  7. nextIndex = this.mask(nextIndex + spreadTwo);
  8. short keyAtIndex = this.keys[nextIndex];
  9. if (keyAtIndex == element)
  10. {
  11. return nextIndex;
  12. }
  13. if (keyAtIndex == EMPTY_KEY)
  14. {
  15. return removedIndex == -1 ? nextIndex : removedIndex;
  16. }
  17. if (keyAtIndex == REMOVED_KEY && removedIndex == -1)
  18. {
  19. removedIndex = nextIndex;
  20. }
  21. }
  22. }

代码示例来源:origin: lealone/Lealone

  1. private void write0(DataBuffer buff, float x) {
  2. int f = Float.floatToIntBits(x);
  3. if (f == FLOAT_ZERO_BITS) {
  4. buff.put((byte) TAG_FLOAT_0);
  5. } else if (f == FLOAT_ONE_BITS) {
  6. buff.put((byte) TAG_FLOAT_1);
  7. } else {
  8. int value = Integer.reverse(f);
  9. if (value >= 0 && value <= DataUtils.COMPRESSED_VAR_INT_MAX) {
  10. buff.put((byte) FLOAT).putVarInt(value);
  11. } else {
  12. buff.put((byte) TAG_FLOAT_FIXED).putFloat(x);
  13. }
  14. }
  15. }

代码示例来源:origin: com.h2database/h2

  1. @Override
  2. public void write(WriteBuffer buff, Object obj) {
  3. if (!(obj instanceof Float)) {
  4. super.write(buff, obj);
  5. return;
  6. }
  7. float x = (Float) obj;
  8. int f = Float.floatToIntBits(x);
  9. if (f == ObjectDataType.FLOAT_ZERO_BITS) {
  10. buff.put((byte) TAG_FLOAT_0);
  11. } else if (f == ObjectDataType.FLOAT_ONE_BITS) {
  12. buff.put((byte) TAG_FLOAT_1);
  13. } else {
  14. int value = Integer.reverse(f);
  15. if (value >= 0 && value <= DataUtils.COMPRESSED_VAR_INT_MAX) {
  16. buff.put((byte) TYPE_FLOAT).putVarInt(value);
  17. } else {
  18. buff.put((byte) TAG_FLOAT_FIXED).putFloat(x);
  19. }
  20. }
  21. }

相关文章