本文整理汇总了Java中sim.util.IntBag类的典型用法代码示例。如果您正苦于以下问题:Java IntBag类的具体用法?Java IntBag怎么用?Java IntBag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntBag类属于sim.util包,在下文中一共展示了IntBag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deduplicate
import sim.util.IntBag; //导入依赖的package包/类
public IntBag deduplicate(IntBag b){
IntBag d = new IntBag();
for (int i = 0; i < b.numObjs; i++){
int o = b.get(i);
if (!d.contains(o)){
d.add(o);
}
}
return d;
}
示例2: position
import sim.util.IntBag; //导入依赖的package包/类
public int position(IntBag b, int num){
int pos = -1;
for (int i = 0; i < b.numObjs; i++){
int bNum = b.get(i);
if (bNum == num){
pos = i;
break;
}
}
return pos;
}
示例3: sortOrder
import sim.util.IntBag; //导入依赖的package包/类
public IntBag sortOrder(double [] b){
DoubleBag db = new DoubleBag();
db.addAll(b);
return sortOrder(db);
}
示例4: getNeighborsMaxDistance
import sim.util.IntBag; //导入依赖的package包/类
/**
* Gets all neighbors of a location that satisfy max( abs(x-X) , abs(y-Y), abs(z-Z) ) <= dist. This region forms a
* cube 2*dist+1 cells across, centered at (X,Y,Z). If dist==1, this
* is equivalent to the twenty-six neighbors surrounding (X,Y,Z), plus (X,Y) itself.
* Places each x, y, and z value of these locations in the provided IntBags xPos, yPos, and zPos, clearing the bags first.
* null may be passed in for the various bags, though it is more efficient to pass in a 'scratch bag' for
* each one.
*
* <p> This function may only run in two modes: toroidal or bounded. Unbounded lookup is not permitted, and so
* this function is deprecated: instead you should use the other version of this function which has more functionality.
* If "bounded",
* then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height,length),
* that is, the width and height of the grid. if "toroidal",
* then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
* locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
* the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
* resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
*
* <p>The origin -- that is, the (x,y,z) point at the center of the neighborhood -- is always included in the results.
*
* <p>This function is equivalent to: <tt>getNeighborsMaxDistance(x,y,dist,toroidal ? Grid3D.TOROIDAL : Grid3D.BOUNDED, true, xPos, yPos, zPos);</tt>
*
* @deprecated
*/
public void getNeighborsMaxDistance( final int x, final int z, final int y, final int dist, final boolean toroidal, IntBag xPos, IntBag yPos, IntBag zPos);
示例5: getMooreLocations
import sim.util.IntBag; //导入依赖的package包/类
/**
* Gets all neighbors of a location that satisfy max( abs(x-X) , abs(y-Y), abs(z-Z) ) <= dist. This region forms a
* cube 2*dist+1 cells across, centered at (X,Y,Z). If dist==1, this
* is equivalent to the twenty-six neighbors surrounding (X,Y,Z), plus (X,Y) itself.
* Places each x, y, and z value of these locations in the provided IntBags xPos, yPos, and zPos, clearing the bags first.
* null may be passed in for the various bags, though it is more efficient to pass in a 'scratch bag' for
* each one.
*
* <p>This function may be run in one of three modes: Grid3D.BOUNDED, Grid3D.UNBOUNDED, and GrideD.TOROIDAL. If "bounded",
* then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height,length),
* that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded
* neighborhood lookup only makes sense if your grid allows locations to actually <i>be</i> outside this box. For example,
* SparseGrid3D permits this but ObjectGrid3D and DoubleGrid3D and IntGrid3D and DenseGrid3D do not. Finally if "toroidal",
* then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
* locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
* the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
* resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
*
* <p>You can also opt to include the origin -- that is, the (x,y,z) point at the center of the neighborhood -- in the neighborhood results.
*/
public void getMooreLocations( final int x, final int y, int z, final int dist, int mode, boolean includeOrigin, IntBag xPos, IntBag yPos, IntBag zPos );
示例6: getNeighborsHamiltonianDistance
import sim.util.IntBag; //导入依赖的package包/类
/**
* Gets all neighbors of a location that satisfy abs(x-X) + abs(y-Y) + abs(z-Z) <= dist. This region
* forms an <a href="http://images.google.com/images?q=octahedron">octohedron</a> 2*dist+1 cells from point
* to opposite point inclusive, centered at (X,Y,Y). If dist==1 this is
* equivalent to the six neighbors above, below, left, and right, front, and behind (X,Y,Z)),
* plus (X,Y,Z) itself.
* Places each x, y, and z value of these locations in the provided IntBags xPos, yPos, and zPos, clearing the bags first.
* null may be passed in for the various bags, though it is more efficient to pass in a 'scratch bag' for
* each one.
*
* <p> This function may only run in two modes: toroidal or bounded. Unbounded lookup is not permitted, and so
* this function is deprecated: instead you should use the other version of this function which has more functionality.
* If "bounded",
* then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height,length),
* that is, the width and height of the grid. if "toroidal",
* then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
* locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
* the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
* resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
*
* <p>The origin -- that is, the (x,y,z) point at the center of the neighborhood -- is always included in the results.
*
* <p>This function is equivalent to: <tt>getNeighborsHamiltonianDistance(x,y,dist,toroidal ? Grid3D.TOROIDAL : Grid3D.BOUNDED, true, xPos, yPos, zPos);</tt>
*
* @deprecated
*/
public void getNeighborsHamiltonianDistance( final int x, final int y, int z, final int dist, final boolean toroidal, IntBag xPos, IntBag yPos, IntBag zPos );
示例7: getVonNeumannLocations
import sim.util.IntBag; //导入依赖的package包/类
/**
* Gets all neighbors of a location that satisfy abs(x-X) + abs(y-Y) + abs(z-Z) <= dist. This region
* forms an <a href="http://images.google.com/images?q=octahedron">octohedron</a> 2*dist+1 cells from point
* to opposite point inclusive, centered at (X,Y,Y). If dist==1 this is
* equivalent to the six neighbors above, below, left, and right, front, and behind (X,Y,Z)),
* plus (X,Y,Z) itself.
* Places each x, y, and z value of these locations in the provided IntBags xPos, yPos, and zPos, clearing the bags first.
* null may be passed in for the various bags, though it is more efficient to pass in a 'scratch bag' for
* each one.
*
* <p>This function may be run in one of three modes: Grid3D.BOUNDED, Grid3D.UNBOUNDED, and GrideD.TOROIDAL. If "bounded",
* then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height,length),
* that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded
* neighborhood lookup only makes sense if your grid allows locations to actually <i>be</i> outside this box. For example,
* SparseGrid3D permits this but ObjectGrid3D and DoubleGrid3D and IntGrid3D and DenseGrid3D do not. Finally if "toroidal",
* then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
* locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
* the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
* resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
*
* <p>You can also opt to include the origin -- that is, the (x,y,z) point at the center of the neighborhood -- in the neighborhood results.
*/
public void getVonNeumannLocations( final int x, final int y, int z, final int dist, int mode, boolean includeOrigin, IntBag xPos, IntBag yPos, IntBag zPos );
示例8: getRadialLocations
import sim.util.IntBag; //导入依赖的package包/类
/**
* Gets all neighbors overlapping with a spherical region centered at (X,Y,Z) and with a radius of dist.
* The measurement rule is Grid2D.ANY, meaning those cells which overlap at all with the region.
* The region is closed, meaning that that points which touch on the outer surface of the sphere will be
* considered members of the region.
*
* <p>Places each x, y, and z value of these locations in the provided IntBags xPos, yPos, and zPos, clearing the bags first.
*
* <p>This function may be run in one of three modes: Grid3D.BOUNDED, Grid3D.UNBOUNDED, and GrideD.TOROIDAL. If "bounded",
* then the neighbors are restricted to be only those which lie within the box ranging from (0,0,0) to (width, height,length),
* that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded
* neighborhood lookup only makes sense if your grid allows locations to actually <i>be</i> outside this box. For example,
* SparseGrid3D permits this but ObjectGrid3D and DoubleGrid3D and IntGrid3D and DenseGrid3D do not. Finally if "toroidal",
* then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
* locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
* the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
* resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
*
* <p>You can also opt to include the origin -- that is, the (x,y,z) point at the center of the neighborhood -- in the neighborhood results.
*/
public void getRadialLocations( final int x, final int y, final int z, final double dist, int mode, boolean includeOrigin, IntBag xPos, IntBag yPos, IntBag zPos );
示例9: getNeighborsMaxDistance
import sim.util.IntBag; //导入依赖的package包/类
/**
* Gets all neighbors of a location that satisfy max( abs(x-X) , abs(y-Y) ) <= dist. This region forms a
* square 2*dist+1 cells across, centered at (X,Y). If dist==1, this
* is equivalent to the so-called "Moore Neighborhood" (the eight neighbors surrounding (X,Y)), plus (X,Y) itself.
* Places each x and y value of these locations in the provided IntBags xPos and yPos, clearing the bags first.
*
* <p> This function may only run in two modes: toroidal or bounded. Unbounded lookup is not permitted, and so
* this function is deprecated: instead you should use the other version of this function which has more functionality.
* If "bounded",
* then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height),
* that is, the width and height of the grid. if "toroidal",
* then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
* locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
* the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
* resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
*
* <p>The origin -- that is, the (x,y) point at the center of the neighborhood -- is always included in the results.
*
* <p>This function is equivalent to: <tt>getNeighborsMaxDistance(x,y,dist,toroidal ? Grid2D.TOROIDAL : Grid2D.BOUNDED, true, xPos, yPos);</tt>
*
* @deprecated
*/
public void getNeighborsMaxDistance( final int x, final int y, final int dist, final boolean toroidal, IntBag xPos, IntBag yPos );
示例10: getMooreLocations
import sim.util.IntBag; //导入依赖的package包/类
/**
* Gets all neighbors of a location that satisfy max( abs(x-X) , abs(y-Y) ) <= dist. This region forms a
* square 2*dist+1 cells across, centered at (X,Y). If dist==1, this
* is equivalent to the so-called "Moore Neighborhood" (the eight neighbors surrounding (X,Y)), plus (X,Y) itself.
* Places each x and y value of these locations in the provided IntBags xPos and yPos, clearing the bags first.
*
* <p>This function may be run in one of three modes: Grid2D.BOUNDED, Grid2D.UNBOUNDED, and Grid2D.TOROIDAL. If "bounded",
* then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height),
* that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded
* neighborhood lookup only makes sense if your grid allows locations to actually <i>be</i> outside this box. For example,
* SparseGrid2D permits this but ObjectGrid2D and DoubleGrid2D and IntGrid2D and DenseGrid2D do not. Finally if "toroidal",
* then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
* locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
* the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
* resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
*
* <p>You can also opt to include the origin -- that is, the (x,y) point at the center of the neighborhood -- in the neighborhood results.
*/
public void getMooreLocations( final int x, final int y, final int dist, int mode, boolean includeOrigin, IntBag xPos, IntBag yPos );
示例11: getNeighborsHamiltonianDistance
import sim.util.IntBag; //导入依赖的package包/类
/**
* Gets all neighbors of a location that satisfy abs(x-X) + abs(y-Y) <= dist. This region forms a diamond
* 2*dist+1 cells from point to opposite point inclusive, centered at (X,Y). If dist==1 this is
* equivalent to the so-called "Von-Neumann Neighborhood" (the four neighbors above, below, left, and right of (X,Y)),
* plus (X,Y) itself.
* Places each x and y value of these locations in the provided IntBags xPos and yPos, clearing the bags first.
*
* <p> This function may only run in two modes: toroidal or bounded. Unbounded lookup is not permitted, and so
* this function is deprecated: instead you should use the other version of this function which has more functionality.
* If "bounded",
* then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height),
* that is, the width and height of the grid. if "toroidal",
* then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
* locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
* the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
* resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
*
* <p>The origin -- that is, the (x,y) point at the center of the neighborhood -- is always included in the results.
*
* <p>This function is equivalent to: <tt>getNeighborsHamiltonianDistance(x,y,dist,toroidal ? Grid2D.TOROIDAL : Grid2D.BOUNDED, true, xPos, yPos);</tt>
*
* @deprecated
*/
public void getNeighborsHamiltonianDistance( final int x, final int y, final int dist, final boolean toroidal, IntBag xPos, IntBag yPos );
示例12: getVonNeumannLocations
import sim.util.IntBag; //导入依赖的package包/类
/**
* Gets all neighbors of a location that satisfy abs(x-X) + abs(y-Y) <= dist. This region forms a diamond
* 2*dist+1 cells from point to opposite point inclusive, centered at (X,Y). If dist==1 this is
* equivalent to the so-called "Von-Neumann Neighborhood" (the four neighbors above, below, left, and right of (X,Y)),
* plus (X,Y) itself.
* Places each x and y value of these locations in the provided IntBags xPos and yPos, clearing the bags first.
*
* <p>This function may be run in one of three modes: Grid2D.BOUNDED, Grid2D.UNBOUNDED, and Grid2D.TOROIDAL. If "bounded",
* then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height),
* that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded
* neighborhood lookup only makes sense if your grid allows locations to actually <i>be</i> outside this box. For example,
* SparseGrid2D permits this but ObjectGrid2D and DoubleGrid2D and IntGrid2D and DenseGrid2D do not. Finally if "toroidal",
* then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
* locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
* the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
* resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
*
* <p>You can also opt to include the origin -- that is, the (x,y) point at the center of the neighborhood -- in the neighborhood results.
*/
public void getVonNeumannLocations( final int x, final int y, final int dist, int mode, boolean includeOrigin, IntBag xPos, IntBag yPos );
示例13: getNeighborsHexagonalDistance
import sim.util.IntBag; //导入依赖的package包/类
/**
* Gets all neighbors located within the hexagon centered at (X,Y) and 2*dist+1 cells from point to opposite point
* inclusive.
* If dist==1, this is equivalent to the six neighbors immediately surrounding (X,Y),
* plus (X,Y) itself.
* Places each x and y value of these locations in the provided IntBags xPos and yPos, clearing the bags first.
*
* <p> This function may only run in two modes: toroidal or bounded. Unbounded lookup is not permitted, and so
* this function is deprecated: instead you should use the other version of this function which has more functionality.
* If "bounded",
* then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height),
* that is, the width and height of the grid. if "toroidal",
* then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
* locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
* the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
* resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
*
* <p>The origin -- that is, the (x,y) point at the center of the neighborhood -- is always included in the results.
*
* <p>This function is equivalent to: <tt>getNeighborsHexagonalDistance(x,y,dist,toroidal ? Grid2D.TOROIDAL : Grid2D.BOUNDED, true, xPos, yPos);</tt>
*
* @deprecated
*/
public void getNeighborsHexagonalDistance( final int x, final int y, final int dist, final boolean toroidal, IntBag xPos, IntBag yPos );
示例14: getHexagonalLocations
import sim.util.IntBag; //导入依赖的package包/类
/**
* Gets all neighbors located within the hexagon centered at (X,Y) and 2*dist+1 cells from point to opposite point
* inclusive.
* If dist==1, this is equivalent to the six neighbors immediately surrounding (X,Y),
* plus (X,Y) itself.
* Places each x and y value of these locations in the provided IntBags xPos and yPos, clearing the bags first.
*
* <p>This function may be run in one of three modes: Grid2D.BOUNDED, Grid2D.UNBOUNDED, and Grid2D.TOROIDAL. If "bounded",
* then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height),
* that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded
* neighborhood lookup only makes sense if your grid allows locations to actually <i>be</i> outside this box. For example,
* SparseGrid2D permits this but ObjectGrid2D and DoubleGrid2D and IntGrid2D and DenseGrid2D do not. Finally if "toroidal",
* then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
* locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
* the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
* resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
*
* <p>You can also opt to include the origin -- that is, the (x,y) point at the center of the neighborhood -- in the neighborhood results.
*/
public void getHexagonalLocations( final int x, final int y, final int dist, int mode, boolean includeOrigin, IntBag xPos, IntBag yPos );
示例15: getRadialLocations
import sim.util.IntBag; //导入依赖的package包/类
/**
* Gets all neighbors overlapping with a circular region centered at (X,Y) and with a radius of dist.
* The measurement rule is Grid2D.ANY, meaning those cells which overlap at all with the region.
* The region is closed, meaning that that points which touch on the outer surface of the circle will be
* considered members of the region.
*
* <p>Places each x and y value of these locations in the provided IntBags xPos and yPos, clearing the bags first.
*
* <p>This function may be run in one of three modes: Grid2D.BOUNDED, Grid2D.UNBOUNDED, and Grid2D.TOROIDAL. If "bounded",
* then the neighbors are restricted to be only those which lie within the box ranging from (0,0) to (width, height),
* that is, the width and height of the grid. If "unbounded", then the neighbors are not so restricted. Note that unbounded
* neighborhood lookup only makes sense if your grid allows locations to actually <i>be</i> outside this box. For example,
* SparseGrid2D permits this but ObjectGrid2D and DoubleGrid2D and IntGrid2D and DenseGrid2D do not. Finally if "toroidal",
* then the environment is assumed to be toroidal, that is, wrap-around, and neighbors are computed in this fashion. Toroidal
* locations will not appear multiple times: specifically, if the neighborhood distance is so large that it wraps completely around
* the width or height of the box, neighbors will not be counted multiple times. Note that to ensure this, subclasses may need to
* resort to expensive duplicate removal, so it's not suggested you use so unreasonably large distances.
*
* <p>You can also opt to include the origin -- that is, the (x,y) point at the center of the neighborhood -- in the neighborhood results.
*/
public void getRadialLocations( final int x, final int y, final double dist, int mode, boolean includeOrigin, IntBag xPos, IntBag yPos );