📄 integerpool.cs
字号:
using System;
namespace OpenNLP.Tools.Util
{
/// <summary> A pool of read-only, unsigned Integer objects within a fixed,
/// non-sparse range. Use this class for operations in which a large
/// number of Integer wrapper objects will be created.
///
/// Created: Sat Oct 27 10:59:11 2001
///
/// </summary>
/// <author> Eric Friedman
/// </author>
/// <version> $Id: IntegerPool.java,v 1.1 2001/10/28 03:17:03 ericdf Exp $
/// </version>
public class IntegerPool
{
private int[] maiTable;
/// <summary> Creates an IntegerPool with 0..size Integer objects.
///
/// </summary>
/// <param name="size">the size of the pool.
/// </param>
public IntegerPool(int size)
{
maiTable = new int[size];
for (int iCurrentValue = 0; iCurrentValue < size; iCurrentValue++)
{
maiTable[iCurrentValue] = iCurrentValue;
} // end of for (int iCurrentValue = 0; iCurrentValue < size; iCurrentValue++)
}
/// <summary> Returns the shared Integer wrapper for <tt>value</tt> if it is
/// inside the range managed by this pool. if <tt>value</tt> is
/// outside the range, a new Integer instance is returned.
///
/// </summary>
/// <param name="inputValue">an <code>int</code> value
/// </param>
/// <returns> an <code>Integer</code> value
/// </returns>
public virtual int GetInteger(int inputValue)
{
if (inputValue < maiTable.Length && inputValue >= 0)
{
return maiTable[inputValue];
}
else
{
return inputValue;
}
}
} // IntegerPool
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -