首页 \ 问答 \ “拆分(regEx)”和“拆分(regEx,0)”之间的Java区别?(Java difference between “split(regEx)” and “split(regEx, 0)”?)

“拆分(regEx)”和“拆分(regEx,0)”之间的Java区别?(Java difference between “split(regEx)” and “split(regEx, 0)”?)

使用split(regEx)split(regEx, 0)之间有什么区别吗?

因为输出是针对我测试的情况相同。 例如:

String myS = this is stack overflow;
String[] mySA = myS.split(' ');

导致mySA === {'this','is','stack,'overflow'}

String myS = this is stack overflow;
String[] mySA = myS.split(' ', 0);

也导致mySA === {'this','is','stack,'overflow'}

这里有“隐藏”的东西吗? 还是需要了解.split(regEx, 0)


Is there any difference between using split(regEx) and split(regEx, 0)?

Because the output is for the cases I tested the same. Ex:

String myS = this is stack overflow;
String[] mySA = myS.split(' ');

results in mySA === {'this','is','stack,'overflow'}

And

String myS = this is stack overflow;
String[] mySA = myS.split(' ', 0);

also results in mySA === {'this','is','stack,'overflow'}

Is there something "hidden" going on here? Or something else which needs to be known about the .split(regEx, 0)?


原文:https://stackoverflow.com/questions/29603365
更新时间:2021-12-18 15:12

最满意答案

执行此操作的最佳方法是使用仅具有白色像素(可以改变alphas)的纹理,并在使用SpriteBatch.setColor(r,g,b,a)绘制它们之前对其进行着色 - 之后设置回Color.WHITE

除了必须暂停逐个像素地转换纹理之外,最大的优点是纹理不需要在自己的文件中设置,但可以与所有其他纹理放在相同的TextureAtlas中没有着色的。 因为没有必要绑定纹理的不同颜色版本, SpriteBatch最终会减少渲染调用,这意味着渲染速度更快。


The best way to do this is to use textures with only white pixels (which varying alphas), and tinting them before drawing them with SpriteBatch.setColor(r,g,b,a)--just set back to Color.WHITE after.

Aside from having to pause to transform the texture pixel-by-pixel, the biggest advantage of this is that the texture doesn't need to be set in its own file, but can be put in the same TextureAtlas as all of the other textures that aren't being tinted. Because it's not necessary to bind different colored versions of the texture, SpriteBatch ends up making a lot fewer rendering calls, which means faster rendering.

相关问答

更多
  • 是的,您一定需要将gdx-stb-truetype jar添加到您的项目中,正如您在编辑中所述。 这里是你将如何使用它,非常直观... 首先你需要声明你的BitmapFont和你将使用的字符...... BitmapFont font; public static final String FONT_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789][_!$%#@|\\/?-+=()*&.;,{}\"´` ...
  • 它可能会说,因为隐藏广告并不能阻止以前从服务器获取广告。 因此,当您隐藏广告时,它仍然算作印象但不会带来金钱并降低平均赚钱(RPM)。 但现在,当您隐藏广告时,它不再提取广告,因此现在不用担心。 It probably says that because hiding ads wasn't stop the fetching ads from server formerly. So when you hide ads it was still counting as impression but not b ...
  • 您是否在扩展AndroidApplication的Android类中初始化它? 它应该看起来像: public void onCreate(final Bundle savedInstanceState) { super.onCreate( savedInstanceState ); this.initialize(new Game2D, false); } 参数“false”告诉应用程序使用OpenGL ES 1.0(GL10): OpenGL ES 1.0 == GL10 OpenGL ...
  • 你在寻找什么称为NinePatch 。 基本上,这是一种特殊的图像,它定义了图像的可拉伸和不可拉伸的部分。 NinePatch的典型用例是Button,因为您通常不希望边缘被拉伸而只是拉伸其余部分。 实例化的一个简单示例是: NinePatch patch = new NinePatch(new Texture(Gdx.files.internal("knob.png")), 12, 12, 12, 12); 有关此示例的更多详细信息,请参阅有关NinePatches的Wiki页面: https : / ...
  • 如果纹理布局在网格中,您可以使用TextureRegion#split(texture,tileWidth,tileHeight)获取纹理的一堆纹理区域。 您也可以使用一组松散图像上的TexturePacker将它们打包成单个纹理,然后使用TextureAtlas加载。 这有一个好处,它可以从每个框架中去除空白以获得更好的打包效果,并且也可以做别致的东西(如果两个框架是相同的,它只会打包一次)。 将您的框架图像命名为anim_1.png,anim_2.png等,然后根据框架编号将所有名为“anim”的纹理区 ...
  • 执行此操作的最佳方法是使用仅具有白色像素(可以改变alphas)的纹理,并在使用SpriteBatch.setColor(r,g,b,a)绘制它们之前对其进行着色 - 之后设置回Color.WHITE 。 除了必须暂停逐个像素地转换纹理之外,最大的优点是纹理不需要在自己的文件中设置,但可以与所有其他纹理放在相同的TextureAtlas中没有着色的。 因为没有必要绑定纹理的不同颜色版本, SpriteBatch最终会减少渲染调用,这意味着渲染速度更快。 The best way to do this is ...
  • 此问题已得到解决。 Libgdx库存在一些错误,这些错误会导致合并不同模型的许多问题(同时模型可以合并而没有任何问题)。 我找到了解决这个问题的合适方法,它让我无法正确使用VBO系统。 有关更多信息,请参阅以下链接: libGDX中的慢模型批处理渲染 http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=10842 This issue has been solved. Libgdx library has some bugs which cause ...
  • 如果你想使用原生的android listview,你应该参考这个 但在大多数情况下,改变活动可能不是一个好主意。 因此,scene2d中的List类将是一个很好的选择。 您可以使用项目数组对其进行初始化,并使用选择更改侦听器来执行加电选择。 有关更多信息,请参阅此 I came accross with the alternative solution. implements gestureListener provided by Libgdx and used pan method.
  • 如果您正在使用scene2d,则不一定需要使用ShapeRenderer渲染某些形状。 scene2d为您提供了一个调试模式,例如在actor周围绘制设置的边界框。 这发生在drawDebug() 当然,您可以覆盖此方法以添加其他形状(将在其中使用ShapeRenderer )。 例如,如果您有一名演员代表一个球,您可能需要围绕演员的边界绘制一个圆以在调试模式下查看可点击区域。 当然,您还应该相应地覆盖collides()方法以进行正确的碰撞检测。 如果您打算在游戏中的不同角色之间进行碰撞检测,请考虑使用b ...
  • 您不需要在Libgdx中部署Screen对象。 Screen对象不会将任何资源加载到内存中,它只是ApplicationAdapter用于委派工作的逻辑类。 查看此内存管理维基部分,它们提供了需要手动处理的类列表。 You do not need to dispose Screen objects in Libgdx. Screen objects do not load any resources into memory, it is merely a Logical class that Applica ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)