Android permission-tree和permission-groupAndroid有什么区别?
private class HSV extends HorizontalScrollView {
public LinearLayout L;
public AbsoluteLayout A;
public HSV(Context context) {
super(context);
L = new LinearLayout(context);
A = new AbsoluteLayout(context);
}
@Override public void addView(View child) {
A.addView(child);
}
void update_scroll() {
removeView(L);
addView(L, 0);
L.removeView(A);
L.addView(A);
A.invalidate();
L.invalidate();
invalidate();
requestLayout();
}
int GetCurrentPos() {
return getScrollX(); // <-- this line if HSV
return getScrollY(); // <-- this line if VSV
}
... few more methods skipped, they will not change at all in 'vertical' …Run Code Online (Sandbox Code Playgroud) 我有多个头文件,每个头文件都必须在数组中附加一个数字来注册它的函数.
目前我在每个头文件中都有一个具有唯一名称的函数,在程序文件中我需要在一个组合函数中调用所有这些函数.
int register1() { return 100; }; //in header1.h
int register2() { return 200; }; //in header2.h
int register3() { return 300; }; //in header3.h
int register4() { return 400; }; //in header4.h
int registered[] = {register1(),register2(),register3(),register4()}; //main.c
Run Code Online (Sandbox Code Playgroud)
但这很不方便,因为我需要在添加或删除头文件时在两个地方进行修改.最好只修改头文件.我正在考虑预处理器定义,所以在每个头文件中我可以使用类似的东西:
#define Registered Registered,100 // header1.h
#define Registered Registered,200 // header2.h
int registered[] = {Registered}; // main.c
Run Code Online (Sandbox Code Playgroud)
但这当然不会编译,因为新的定义重新定义旧的定义.那么有没有办法追加一个定义?或者在不修改两个文件的情况下将数字附加到数组的其他方法?
这是C,而不是C++,否则我会使用一个带有构造函数的类实例,它只会写入一个数组.有些想法:
struct __header1{ __header1() {
global_array[global_array_ptr++] = 100;
} } __header1_inst;
Run Code Online (Sandbox Code Playgroud)
然后将其转换为一个漂亮的宏:
#define register(hdr, func) struct __header##hdr{ __header##hdr() { \
global_array[global_array_ptr++] = func; …Run Code Online (Sandbox Code Playgroud) 我读过Armin Ronacher的 Stop Being Cute and Clever文章,他给出.map()了JavaScript 中奇怪实现的例子,但他对此没有任何解释,我很好奇,因为它对我没有意义.所以为什么
console.log(["1", "2", "3"].map(parseInt))
Run Code Online (Sandbox Code Playgroud)
输出:
[ 1, NaN, NaN ]
Run Code Online (Sandbox Code Playgroud) <center><canvas id=c1 width=400 height=400></canvas>
<script>
ctx = c1.getContext('2d')
ctx.fillStyle = '#7ef' // draw blue background with the darker frame
ctx.fillRect(0, 0, 400, 400)
ctx.fillStyle = '#9ff'
ctx.fillRect(10, 10, 400-20, 400-20)
var X = 75, W = 50, G = 20
ctx.lineWidth = 10
var colors = ['blue', 'black', 'red', 'yellow', 'green']
var args = [
[X,X,W],
[X+W+W+G,X,W],
[X+W+W+G+W+W+G,X,W],
[X+W+G/2,X+W,W],
[X+W+G/2+W+W+G,X+W,W]]
while (colors.length > 0) {
ctx.strokeStyle = colors.shift()
ctx.beginPath()
ctx.arc.apply(ctx, args.shift().concat([0,Math.PI*2,true]))
ctx.stroke()
}
</script>
Run Code Online (Sandbox Code Playgroud)
以上是我此时的代码.我的目标是娱乐孩子,有12岁男孩,但我的代码不够惊人,是否可以通过删除所有手工编码的坐标来减少烦恼?使戒指"互联"也很酷,但如何实现呢?
这是我当前代码的输出:

这就是奥运会应该是这样的:

有没有办法避免this.在方法体中的每个成员之前使用?
JavaScript在许多方面都是惊人的,但有一点让人难以理解的是你必须this.在每个成员之前使用它:
TList.on_key = function(key) {
if (key == 116) {
this.sid++;
if (this.sid > this.items.length - 1) this.sid = this.items.length - 1
if (this.sid >= this.d + (this.h * this.columns)) this.d++
}
Run Code Online (Sandbox Code Playgroud)
没有所有这些将会更容易阅读this.:
TList.on_key = function(key) {
if (key == 116) {
sid++;
if (sid > items.length - 1) sid = items.length - 1
if (sid >= d + (h * columns)) d++
}
Run Code Online (Sandbox Code Playgroud) 当我尝试安装npm它时经常失败(例如,更常见的是apt-get),并且它将显示"查看日志文件以获取详细信息"或"在目录中生成失败".但是当我尝试检查目录时说它将无法找到.如果在安装过程中出现任何问题,NPM是否只删除它刚下载的所有内容?为什么它会告诉我检查目录然后删除它?
在一些旧的C/C++图形相关代码中,我必须移植到Java和JavaScript,我发现:
b = (b+1 + (b >> 8)) >> 8; // very fast
Run Code Online (Sandbox Code Playgroud)
哪里b是short int蓝色,而相同的代码会被视作r和b(红色和蓝色).评论没有帮助.
除了明显的转移和添加之外,我无法弄清楚它的作用.我可以不理解地移动,我只是出于好奇而问.
在一个复杂的程序中,我试图尽可能地应用函数式编程模式,一个问题是许多配置文件刚刚加载并成为可从程序中的任何位置访问的全局变量。这种方法会导致纠缠。我应该如何以函数式编程风格处理配置文件?