首页
\
问答
\
打破循环和返回值,angularJs中的递归函数(break for loop and return value , recursive function in angularJs)
打破循环和返回值,angularJs中的递归函数(break for loop and return value , recursive function in angularJs)
我有一个递归函数来查找键并返回其值,这是我的代码
$scope.findSelected = function (object, name){ //var key = ''; for (var i =0 ; i< object.length; i++){ var children =object[i]; var vName =children.Value.Name; if(vName=== name ){ var key=children.Value.Key; break; }else { key = $scope.findSelected(children.Children, name); } } return key; };
其中vName === name我必须返回键,但不能再循环播放,我想我有任何狡猾的事情和功能返回不明
i have a recursive function to find key and return his value, this is my code
$scope.findSelected = function (object, name){ //var key = ''; for (var i =0 ; i< object.length; i++){ var children =object[i]; var vName =children.Value.Name; if(vName=== name ){ var key=children.Value.Key; break; }else { key = $scope.findSelected(children.Children, name); } } return key; };
where vName === name i have to return key, but not work the loop play again, I think I've any dodgy thing and function return unidentified
原文:https://stackoverflow.com/questions/30218681
更新时间:2021-01-17 06:01
最满意答案
在大多数实现中,该运算符对签名类型进行
arithmetic shift
,因此它保留了sign
位(最左边的位),在本例中为1
。正如@Clifford正确指出的那样,语言标准将
>>
的实现留给了实现者。详情请参阅维基百科文章 。
Under most implementations, that operator does an
arithmetic shift
for signed types, so it preserves thesign
bit (which is the leftmost bit), in this case1
.As @Clifford correctly pointed out, the language standard leaves the implementation of
>>
up to the implementor.See the Wikipedia article for details.
相关问答
更多-
C中的按位运算(Bitwise operation in C)[2023-08-03]
char c1 = 0xFF; // -1 int shifted = c1 << 8; //-256 (-1 * 256) 为了移位, c1被提升为int ,所以它仍然是-1,移位负int是实现定义的,但是你的实现看起来像大多数一样并且将它移位就像它是unsigned位模式一样,所以左移八个地方乘以256。 printf( "%d, %x\n", shifted, shifted ); -256, ffffff00 正如所料。 二进制补码中-256的位模式为0xFFFFFF00 (32位int ) ... -
C程序内存违规(C programme memory violation)[2022-10-01]
写入字符串文字会产生未定义的行为,因此允许编译器在您执行此操作时执行任何操作。 简单的答案是Turbo C ++编译为实模式,因此没有任何内存受到保护。 编译器和操作系统都不会阻止你在任何地方写任何东西。 Writing to a string literal gives undefined behavior, so the compiler is allowed to do anything it wants when you do that. The simple answer is that Turb ... -
在进行位操作时更容易unsigned类型开始 。 由于@coderredoc询问了各种平台的解决方案,甚至还有不常见的解决方案: 使用int : 当int diff为负时,转换为unsigned (通过使用unsigned掩码)可能会改变其位模式。 一个int可能每个“字节”多于8位。 减小sizeof(int)*8正确性。 各种整数类型可能有填充(罕见)。 减小sizeof(int)*CHAR_BIT正确性。 // OP wants to report first bit index as 1. 0 i ...
-
您需要确定您感兴趣的不同部分的位范围。查看列表,主要类型有2个十六进制数字,子类型有4个数字。 使用AND( & )将它们分开。 major = type & 0xff0000; subtype = type & 0x00ffff; You need to determine the bit ranges of the different pieces you're interested in. Looking at the list, there are 2 hex digits devoted to ...
-
C - 按位操作(C - Bitwise manipulation)[2022-10-04]
这被称为“混淆”:编写不必要的复杂代码,以使某些东西看起来更高级。 查看子表达式x<这是写入内存中的一个随机位置: commands>>cmnd>>file; 因为cmnd (和file )是未初始化的指针。 使用std::string而不是char*并立即检查IO操作的结果(不要使用while(input.good()) ,请参阅为什么“while(!feof(file))”总是错误的?为什么) : std::string cmnd; std::string file; if (commands >> cmnd >> file) { } ==运算符重载为std::string因此s ...C:按位不在某位(C: Bitwise NOT on certain bit)[2021-09-24]
与要翻转的位进行XOR。 int c = 0x10; // 10000b int m = 0x08; // 01000b c ^= m; // 11000b XOR with the bits that you want to flip. int c = 0x10; // 10000b int m = 0x08; // 01000b c ^= m; // 11000b在大多数实现中,该运算符对签名类型进行arithmetic shift ,因此它保留了sign位(最左边的位),在本例中为1 。 正如@Clifford正确指出的那样,语言标准将>>的实现留给了实现者。 详情请参阅维基百科文章 。 Under most implementations, that operator does an arithmetic shift for signed types, so it preserves the sign bit (which is the leftmost bit ...使用按位运算(Using bitwise operations)[2022-04-29]
按位运算非常有用,教授。 Knuth给他们写了一本书: http ://www.amazon.com/The-Computer-Programming-Volume-Fascicle/dp/0321580508 仅举几个最简单的:int乘法和除以2的幂(使用左右移位),mod相对于2的幂,掩蔽等等。 使用按位操作时,请确保提供有关正在进行的操作的充分注释。 但是,您的示例, data[c]>128不适用于IMO,只是保持这种方式。 但是如果你想计算data[c] % 128那么data[c] & 0x7f要 ...来自维基百科: 按位AND运算符是单个&符号:&。 它只是AND的一种表示,它对操作数的位而不是操作数的真值进行处理。 按位二进制AND以二进制形式对数字的每个位置中的位进行逻辑AND(如上表所示)。 在您的示例110010和1 , 1被认为是000001 ,然后每个位都是有效的,您将得到结果。 事实上,我使用这种方法: 1&number来检查偶数和奇数。 这是如何: if(1 & num) printf("it is odd"); else printf("it is even"); 这是它的 ...相关文章
更多- 两种js function 声明方式
- error C2668: 'M' : ambiguous call to overloaded function
- AngularJS资源
- AngularJs视频教程
- function-Oceanus配置说明
- Angularjs 中文视频教程
- 2013年度最强AngularJS资源合集
- webservice的返回值问题
- 【JavaScript】 2013年度最强AngularJS资源合集
- Tomcat源码里,return (factory)有特殊作用么
最新问答
更多- 您如何使用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)