Whatever message this page gives is out now! Go check it out!
structEvery(struct, closure [, parallel] [, maxThreadCount])structObj.Every(callback)Parameter | Required/Optional | Description |
struct | Required | Struct in which all values are to be searched. |
callback | Required | Function that encapsulates the criteria. |
parallel | Optional | True if you want to enable parallel programming. |
maxThreadCount | Optional | The number of threads the function can execute. The number of threads must be between 1-50. If the value exceeds 50, there is an exception. |
<cfscript>
mystruct = {a=1,b=2,c=3};
doesValExist=(key,value,struct)=>return value!=1
writeoutput(structEvery(mystruct,doesValExist)) // Returns False
</cfscript><cfscript>
structEven={a=2,b=4,c=8,d=10,e=12}
isEven=(key,value)=>return value%2==0
writeOutput(StructEvery(structEven,isEven)) // Returns True
</cfscript><cfscript>
structEven={a=2,b=4,c=8,d=10,e=12}
isEven=(key,value)=>return value%2==0
writeOutput(structEven.Every(isEven)) // Returns True
</cfscript><cfscript>
mystruct={"key1":"aval","key2":"aval1","key3":"aval2"}
result=StructEvery(struct=mystruct,callback=function(key,val){
if (val.startswith("a"))
return 1
else
return 0
}
)
writeOutput(result)
</cfscript><cfscript>
ordstruct=["key1":"abc","key2":"def","key3":"sss"]
lambdaFunc= key => key.contains("key")
writeoutput(ordstruct.Every(lambdaFunc))
</cfscript><cfscript>
mystruct= Structnew("ordered");
for(i=1;i<=10000;i++){
mystruct.insert("key#i#","val#i#")
}
function callback(key,val){
if(isObject(val))
return false
return true
}
writeoutput(mystruct.some(callback,false))
writeoutput(structsome(struct=mystruct,callback=callback,parallel=true,maxthreadcount=10))
writeoutput(structsome(struct=mystruct,callback=callback,parallel=true))
try{
writeoutput(structsome(struct=mystruct,callback=callback,parallel=true,maxthreadcount=-10))}
catch(any e){
writeoutput("<br>Type: " & e.type & " Message:" & e.message )
}
try{
writeoutput(structsome(struct=mystruct,callback=callback,parallel=true,maxthreadcount=100))}
catch(any e){
writeoutput("<br>Type: " & e.type & " Message:" & e.message )
}
</cfscript>