com.graphhopper.util.Helper.idealIntArraySize()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(151)

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

Helper.idealIntArraySize介绍

暂无

代码示例

代码示例来源:origin: graphhopper/graphhopper

  1. /**
  2. * Creates a new SparseIntIntArray containing no mappings that will not require any additional
  3. * memory allocation to store the specified number of mappings.
  4. */
  5. public SparseIntIntArray(int cap) {
  6. try {
  7. cap = Helper.idealIntArraySize(cap);
  8. mKeys = new int[cap];
  9. mValues = new int[cap];
  10. mSize = 0;
  11. } catch (OutOfMemoryError err) {
  12. System.err.println("requested capacity " + cap);
  13. throw err;
  14. }
  15. }

代码示例来源:origin: graphhopper/graphhopper

  1. /**
  2. * Puts a key/value pair into the array, optimizing for the case where the key is greater than
  3. * all existing keys in the array.
  4. */
  5. public int append(int key, int value) {
  6. if (mSize != 0 && key <= mKeys[mSize - 1]) {
  7. return put(key, value);
  8. }
  9. if (mGarbage && mSize >= mKeys.length) {
  10. gc();
  11. }
  12. int pos = mSize;
  13. if (pos >= mKeys.length) {
  14. int n = Helper.idealIntArraySize(pos + 1);
  15. int[] nkeys = new int[n];
  16. int[] nvalues = new int[n];
  17. System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
  18. System.arraycopy(mValues, 0, nvalues, 0, mValues.length);
  19. mKeys = nkeys;
  20. mValues = nvalues;
  21. }
  22. mKeys[pos] = key;
  23. mValues[pos] = value;
  24. mSize = pos + 1;
  25. return pos;
  26. }

代码示例来源:origin: graphhopper/graphhopper

  1. int n = Helper.idealIntArraySize(mSize + 1);

代码示例来源:origin: com.graphhopper/graphhopper-core

  1. /**
  2. * Creates a new SparseIntIntArray containing no mappings that will not require any additional
  3. * memory allocation to store the specified number of mappings.
  4. */
  5. public SparseIntIntArray(int cap) {
  6. try {
  7. cap = Helper.idealIntArraySize(cap);
  8. mKeys = new int[cap];
  9. mValues = new int[cap];
  10. mSize = 0;
  11. } catch (OutOfMemoryError err) {
  12. System.err.println("requested capacity " + cap);
  13. throw err;
  14. }
  15. }

代码示例来源:origin: com.rgi-corp/graphhopper

  1. /**
  2. * Creates a new SparseIntIntArray containing no mappings that will not require any additional
  3. * memory allocation to store the specified number of mappings.
  4. */
  5. public SparseIntIntArray(int cap) {
  6. try {
  7. cap = Helper.idealIntArraySize(cap);
  8. mKeys = new int[cap];
  9. mValues = new int[cap];
  10. mSize = 0;
  11. } catch (OutOfMemoryError err) {
  12. System.err.println("requested capacity " + cap);
  13. throw err;
  14. }
  15. }

代码示例来源:origin: com.graphhopper/graphhopper

  1. /**
  2. * Creates a new SparseIntIntArray containing no mappings that will not require any additional
  3. * memory allocation to store the specified number of mappings.
  4. */
  5. public SparseIntIntArray( int cap )
  6. {
  7. try
  8. {
  9. cap = Helper.idealIntArraySize(cap);
  10. mKeys = new int[cap];
  11. mValues = new int[cap];
  12. mSize = 0;
  13. } catch (OutOfMemoryError err)
  14. {
  15. System.err.println("requested capacity " + cap);
  16. throw err;
  17. }
  18. }

代码示例来源:origin: com.graphhopper/graphhopper-core

  1. /**
  2. * Puts a key/value pair into the array, optimizing for the case where the key is greater than
  3. * all existing keys in the array.
  4. */
  5. public int append(int key, int value) {
  6. if (mSize != 0 && key <= mKeys[mSize - 1]) {
  7. return put(key, value);
  8. }
  9. if (mGarbage && mSize >= mKeys.length) {
  10. gc();
  11. }
  12. int pos = mSize;
  13. if (pos >= mKeys.length) {
  14. int n = Helper.idealIntArraySize(pos + 1);
  15. int[] nkeys = new int[n];
  16. int[] nvalues = new int[n];
  17. System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
  18. System.arraycopy(mValues, 0, nvalues, 0, mValues.length);
  19. mKeys = nkeys;
  20. mValues = nvalues;
  21. }
  22. mKeys[pos] = key;
  23. mValues[pos] = value;
  24. mSize = pos + 1;
  25. return pos;
  26. }

代码示例来源:origin: com.rgi-corp/graphhopper

  1. /**
  2. * Puts a key/value pair into the array, optimizing for the case where the key is greater than
  3. * all existing keys in the array.
  4. */
  5. public int append(int key, int value) {
  6. if (mSize != 0 && key <= mKeys[mSize - 1]) {
  7. return put(key, value);
  8. }
  9. if (mGarbage && mSize >= mKeys.length) {
  10. gc();
  11. }
  12. int pos = mSize;
  13. if (pos >= mKeys.length) {
  14. int n = Helper.idealIntArraySize(pos + 1);
  15. int[] nkeys = new int[n];
  16. int[] nvalues = new int[n];
  17. System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
  18. System.arraycopy(mValues, 0, nvalues, 0, mValues.length);
  19. mKeys = nkeys;
  20. mValues = nvalues;
  21. }
  22. mKeys[pos] = key;
  23. mValues[pos] = value;
  24. mSize = pos + 1;
  25. return pos;
  26. }

代码示例来源:origin: com.graphhopper/graphhopper

  1. /**
  2. * Puts a key/value pair into the array, optimizing for the case where the key is greater than
  3. * all existing keys in the array.
  4. */
  5. public int append( int key, int value )
  6. {
  7. if (mSize != 0 && key <= mKeys[mSize - 1])
  8. {
  9. return put(key, value);
  10. }
  11. if (mGarbage && mSize >= mKeys.length)
  12. {
  13. gc();
  14. }
  15. int pos = mSize;
  16. if (pos >= mKeys.length)
  17. {
  18. int n = Helper.idealIntArraySize(pos + 1);
  19. int[] nkeys = new int[n];
  20. int[] nvalues = new int[n];
  21. System.arraycopy(mKeys, 0, nkeys, 0, mKeys.length);
  22. System.arraycopy(mValues, 0, nvalues, 0, mValues.length);
  23. mKeys = nkeys;
  24. mValues = nvalues;
  25. }
  26. mKeys[pos] = key;
  27. mValues[pos] = value;
  28. mSize = pos + 1;
  29. return pos;
  30. }

代码示例来源:origin: com.graphhopper/graphhopper

  1. int n = Helper.idealIntArraySize(mSize + 1);

代码示例来源:origin: com.graphhopper/graphhopper-core

  1. int n = Helper.idealIntArraySize(mSize + 1);

代码示例来源:origin: com.rgi-corp/graphhopper

  1. int n = Helper.idealIntArraySize(mSize + 1);

相关文章