search for: hasnext

Displaying 15 results from an estimated 15 matches for "hasnext".

2008 May 13
0
[LLVMdev] Iterator protocols
...ot;exceptional" happens. OTOH, > the Java case is also made worse by the fact that a large part of the > time you'll be using the more expensive interface dispatching, rather > than simple vtable dispatching. How dynamic is your language? Is it possible that the resolution of the hasNext method could change as the loop executes? If not, it would be neat to find a way to resolve the hasNext callee once, before the loop, and then just make a simple call on each iteration. Dan
2008 May 13
6
[LLVMdev] Iterator protocols
...tion of efficiency of unwinds. I'm mulling over whether to use the Java-style or Python-style iterator protocol for my language. The Python style is to have a special exception (StopIteration) that is thrown when the end of the sequence is reached. The Java style is to have a separate "hasNext" method on the iterator object that says whether or not the sequence is finished. So the question is, what's the trade-off. In most languages that support exceptions, you tend to think of exceptions as expensive operations that should only be thrown if something truly "exceptional...
2009 Oct 13
1
for loop over S4
...to ) + }) [1] "as.list" > > for( i in o ){ + cat( i, "\n" ) + } 1 2 3 4 Obviously that is the cheap way of doing it, something better would be to abstract a bit more what is an "iterator". For example in java iterators implement just two methods : hasNext() that indicates if there is a next object and next() that returns the next object. For the long story, one motivation for this is actually to deal with java iterators (with the devel version of rJava, and this patch), you might do something like this: > v <- new( J("java/util/Ve...
2008 May 13
2
[LLVMdev] Iterator protocols
..., the Java case is also made worse by >> the fact that a large part of the time you'll be using the more >> expensive interface dispatching, rather than simple vtable >> dispatching. > > How dynamic is your language? Is it possible that the resolution of > the hasNext method could change as the loop executes? If not, it > would be neat to find a way to resolve the hasNext callee once, > before the loop, and then just make a simple call on each iteration. I wonder if it would be worthwhile to have a flag on loads to mark them as immutable. A flag fro...
2012 Sep 19
1
java-swig TermIterator
...d now. I'm struggling with the new design of the TermIterator. More specifically, I can't tell when I've reached the end of the list of terms for my document. If I keep calling next(), it will eventually crash in the C++ code and cause the JVM to crash as well, fair enough. If I call hasNext(), it always returns false, even though there are more terms that I can actually retrieve by calling next(). If I try to compare my iterator to the termListEnd() of my document, it always returns false as well. I've tried comparison with both == and equals() just to be sure. There must be som...
2009 May 25
2
Looping through java hashmap from ruby through rjb
Greetings. I am trying to list all keys in a java.util.HashMap field. The Java code to do this looks like: # Collection c = hMap.values(); # # //obtain an Iterator for Collection # Iterator itr = c.iterator(); # # //iterate through HashMap values iterator # while(itr.hasNext()) System.out.println(itr.next()); So, I took a stab at the ruby version: # I have a java hashmap called fields that was created using iText thusly reader = pdfreader.new( "pdf_file.pdf" ) @form = reader.getAcroFields() fields = @form.getFields() # this is a hashmap of all fields o...
2008 May 16
0
[LLVMdev] Iterator protocols
...is also made worse by >>> the fact that a large part of the time you'll be using the more >>> expensive interface dispatching, rather than simple vtable >>> dispatching. >> >> How dynamic is your language? Is it possible that the resolution of >> the hasNext method could change as the loop executes? If not, it >> would be neat to find a way to resolve the hasNext callee once, >> before the loop, and then just make a simple call on each iteration. > > I wonder if it would be worthwhile to have a flag on loads to mark > them as immut...
2009 Sep 15
3
[LLVMdev] My LLVM Project
...in the sequence, after which it returns void, i.e. nothing. LLVM's ability to efficiently return small aggregate types is critical to making this perform well. Ideally, the Tart iterator protocol ought to be faster than either Java Enumerators (which requires two icalls per loop, one for hasNext() and one for next()), or Python's iterators (which depend on exceptions to signal the end of the sequence.) To use the iterator interface, you can use the convenient "for .. in" syntax, similar to Python. Here's a snippet from one of my unit tests: def sum(nums:int...) -&g...
2009 Sep 15
0
[LLVMdev] My LLVM Project
...erface looks like: > >   interface Iterator[%T] { >     def next -> T or void; >   } So this would be something like: template <class T> virtual class Iterator { T next(); // or void? }; So the power of having two types of return parameters is that you save function calls (hasNext())? >   def sum(nums:int...) -> int { >     var sum = 0; >     for i in nums { >       sum += i; >     } >     return sum; >   } I see you don't have types for variables, only for containers, templates and functions. And yet you say your language is statically-typed....
2016 Mar 18
1
for in r-devel
Regarding, this news item for r-devel: ?for()? loops are generalized to iterate over any object with ?[[? and ?length()? methods. Thanks to Herv? Pag?s for the idea and the patch. Below dd is an object for which [[ and length work but the result is still numeric rather than Date class in "R Under development (unstable) (2016-03-15 r70334)" as observed in the comments to:
2010 Jan 14
0
itertools 0.1-1
...e "itertools" package is strongly inspired by the Python itertools module, and includes a number of functions of the same name. There are a variety of functions that create iterators for splitting, chunking, repeating, recycling, zipping, and filtering your data. There is also an "ihasNext" function, written by Hadley Wickham, that adds a "hasNext" method to any iterator, making it easier to get values from an iterator without the use of the "foreach" function. Hadley also contributed some utility functions for writing your own iterators. - Steve Weston __...
2010 Jan 14
0
itertools 0.1-1
...e "itertools" package is strongly inspired by the Python itertools module, and includes a number of functions of the same name. There are a variety of functions that create iterators for splitting, chunking, repeating, recycling, zipping, and filtering your data. There is also an "ihasNext" function, written by Hadley Wickham, that adds a "hasNext" method to any iterator, making it easier to get values from an iterator without the use of the "foreach" function. Hadley also contributed some utility functions for writing your own iterators. - Steve Weston __...
2013 Jul 23
0
Function apply
...40,replace=TRUE),nrow=140) #either res1<-do.call(rbind,lapply(split(as.data.frame(X),((seq_len(nrow(X))-1)%/%10)+1),function(x) apply(x,2,mean))) #or ?res2<-t(sapply(split(as.data.frame(X),((seq_len(nrow(X))-1)%/%10)+1),colMeans)) ?identical(res1,res2) #[1] TRUE #orlibrary(itertools) it<-ihasNext(isplitRows(X,chunkSize=10)) ?while(hasNext(it)){ ?print( apply(nextElem(it),2,mean)) ?} #[1] 23.4 29.1 31.5 #[1] 28.2 21.8 17.2 #[1] 14.3 24.3 36.4 #[1] 22.2 25.2 24.2 #[1] 28.5 22.6 27.3 #[1] 19.6 25.6 20.0 #[1] 25.7 16.3 27.9 #[1] 20.0 24.8 26.7 #[1] 26.3 30.0 33.0 #[1] 21.9 24.0 32.3 #[1] 25.6 2...
2006 Jan 20
4
REST API''s and querying a graph of objects
Hey all, I am wondering if anyone has given thought to using REST / XPath as querying mechanism. That way you could have a URL that actually maps to a collection of records (objects, really) that meet a certain criteria and that are sorted a certain way. Mike Pence
2005 Aug 04
3
SIPPeersAction class file not found in the Asterisk-java.jar file
Hello Everybody, I am working on Fastagi and I am making use of Asterisk-java. But I don't find the class file for SIPPeersAction. Hence I am getting the error message when compiling my java code. ---------------------------------------------------------------------------- ------------------------------------------------ [root@localhost asterisk-java-0.1]#