为什么ArrayDeque类在pollFirst方法中使用按位运算?(Why the ArrayDeque class use bitwise operation in the pollFirst method?)
我通过java源代码看看尝试学习集合的实现。 在ArrayDeque类中发现了一件有趣的事情。
public E pollFirst() { int h = head; @SuppressWarnings("unchecked") E result = (E) elements[h]; // Element is null if deque empty if (result == null) return null; elements[h] = null; // Must null out slot head = (h + 1) & (elements.length - 1); return result; } public E pollLast() { int t = (tail - 1) & (elements.length - 1); @SuppressWarnings("unchecked") E result = (E) elements[t]; if (result == null) return null; elements[t] = null; tail = t; return result; }
以下2行是什么意思? 这是一个按位操作吗? 为什么他们使用它,这里的目的是什么?
head = (h + 1) & (elements.length - 1); int t = (tail - 1) & (elements.length - 1);
我知道一个使用按位的方案是在1个变量中打包2个值。 但似乎事实并非如此。
I look through java source code try to learn the implementation of collection. Found a interesting thing in the ArrayDeque class.
public E pollFirst() { int h = head; @SuppressWarnings("unchecked") E result = (E) elements[h]; // Element is null if deque empty if (result == null) return null; elements[h] = null; // Must null out slot head = (h + 1) & (elements.length - 1); return result; } public E pollLast() { int t = (tail - 1) & (elements.length - 1); @SuppressWarnings("unchecked") E result = (E) elements[t]; if (result == null) return null; elements[t] = null; tail = t; return result; }
What does the following 2 lines mean? Is it a bitwise operation? Why they use it and what's the purpose here?
head = (h + 1) & (elements.length - 1); int t = (tail - 1) & (elements.length - 1);
I know one scenario to use the bitwise is to pack 2 values in 1 variable. But it seems this is not the case.
原文:https://stackoverflow.com/questions/36825213
最满意答案
该网站在Chrome浏览器中使用F12发送了大量错误消息,显然你的www-embed-player-new.js导致了这个问题。 甚至Edge都没有正确运行网站。 我认为您需要Chrome扩展程序才能使其正常运行。
我建议你更改导入视频的插件。 点击此处输入链接说明
编辑:Chrome插件谷歌搜索停止错误消息,但仍然无法正常工作。
The problem was with the wordpress loop on the single.php page. A wrong code snippet caused the issue.
Fixed!
相关问答
更多-
要根据需要使用div包装Youtube iframe,只需使用此... $(function() { $("iframe[src*=www.youtube.com]").wrap(""); }); 这将在文档加载完毕后运行。 它将在src属性中找到所有带有字符串www.youtube.com iframe,并将它们包装在所需的div中。 显然,如果您稍后再向页面添加iframe并且不重新加载,那么您将需要再次运行该代码。 如果你这样做那 ...
-
谢谢brasolfilo,你的建议引导我朝着正确的方向前进。 我假设嵌入是自动的自定义“视频”字段。 不是这种情况。 对于希望为视频存档页面获取视频的任何人,首先需要在帖子上创建此自定义字段 第1步:阅读http://codex.wordpress.org/Custom_Fields 基本上你是在创建你的自定义字段(我命名为我的视频,你可以命名它) 第2步:在你的循环中 while ( have_posts() ) : the_post(); $id = $post->ID; ...
-
YouTube iFrame由于页边空白而不可点击(Bootstrap)(YouTube iFrame unclickable because of margins (Bootstrap))[2022-01-22]
您是否在谈论“Solitaire Android App”中的小视频? 如果是这样,那么它就被相对定位在其他相对/绝对定位的“覆盖”它的东西之中。 给.embed响应一个z-index:1; Are you talking about the small video in, say, "Solitaire Android App"? If so, it's being relatively positioned among other relative/absolutely positioned thing ... -
您始终可以嵌入视觉效果,然后允许视频从一开始就通过点击进行播放。 您可以将视觉效果视为相当高的dpi,因此质量保持不变。 You can always embed the visual and then allow the video to play with the click through from the beginning. You can get the visual to be a pretty high dpi as well so the quality remains in tact.
-
WordPress 支持从某些网站(包括YouTube) 自动嵌入 。 只需将YouTube视频的网址添加到您的帖子内容中,WordPress就会自动为您创建嵌入。 WordPress supports automatic embedding from certain sites, including YouTube. Simply add the YouTube video's URL to your post content, and WordPress will automatically creat ...
-
从YouTube视频中拉取大图片的格式是http://img.youtube.com/vi/A4a0xZMMlqE/0.jpg ,用视频ID替换“A4a0xZMMlqE”。 我认为设置这个最简单的方法是忘记将其用作特色图像,但只是将其动态地拉入模板中。 因此,在您的文章中,制作一个自定义字段,用于保存YouTube视频ID并在模板中进行如下操作:该网站在Chrome浏览器中使用F12发送了大量错误消息,显然你的www-embed-player-new.js导致了这个问题。 甚至Edge都没有正确运行网站。 我认为您需要Chrome扩展程序才能使其正常运行。 我建议你更改导入视频的插件。 点击此处输入链接说明 编辑:Chrome插件谷歌搜索停止错误消息,但仍然无法正常工作。 The problem was with the wordpress loop on the single.php page. A wrong code snippet caus ...
如何在Wordpress模板页面中嵌入YouTube视频?(How can I embed a youtube video in a Wordpress template page?)[2022-01-16]
试试do_shortcode() https://developer.wordpress.org/reference/functions/do_shortcode/ 对于youtube echo do_shortcode( '[embed]https://www.youtube.com/user/bluehost?v=zQ-eL7zH6rQ[/embed]' ); Try do_shortcode() https://developer.wordpress.org/reference/functions/ ...帮助youtube嵌入!(Help with youtube embed!)[2023-07-03]
您可以使用jQuery并简单地将id="yt-video"到您的嵌入代码中。 请务必在HTML中引用jQuery( https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js )。 然后添加这个简单的jQuery: ...使用下面的任何代码段将允许浏览器通过创建可在任何设备上正确缩放的内在比率,根据其包含块的宽度确定视频尺寸。