pub struct JMapIter<'map, 'local, 'other_local_1: 'obj_ref, 'obj_ref, 'iter_local> { /* private fields */ }
Expand description
An iterator over the keys and values in a map. See JMap::iter
for more
information.
TODO: make the iterator implementation for java iterators its own thing and generic enough to use elsewhere.
Implementations§
source§impl<'map, 'local, 'other_local_1: 'obj_ref, 'obj_ref, 'iter_local> JMapIter<'map, 'local, 'other_local_1, 'obj_ref, 'iter_local>
impl<'map, 'local, 'other_local_1: 'obj_ref, 'obj_ref, 'iter_local> JMapIter<'map, 'local, 'other_local_1, 'obj_ref, 'iter_local>
sourcepub fn next<'other_local_2>(
&mut self,
env: &mut JNIEnv<'other_local_2>
) -> Result<Option<(JObject<'other_local_2>, JObject<'other_local_2>)>>
pub fn next<'other_local_2>( &mut self, env: &mut JNIEnv<'other_local_2> ) -> Result<Option<(JObject<'other_local_2>, JObject<'other_local_2>)>>
Advances the iterator and returns the next key-value pair in the
java.util.Map
, or None
if there are no more objects.
See JMap::iter
for more information.
This method creates two new local references. To prevent excessive
memory usage or overflow error, the local references should be deleted
using JNIEnv::delete_local_ref
or JNIEnv::auto_local
before the
next loop iteration. Alternatively, if the map is known to have a
small, predictable size, the loop could be wrapped in
JNIEnv::with_local_frame
to delete all of the local references at
once.
This method returns:
Ok(Some(_))
: if there was another key-value pair in the map.Ok(None)
: if there are no more key-value pairs in the map.Err(_)
: if there was an error calling the Java method to get the next key-value pair.
This is like std::iter::Iterator::next
, but requires a parameter of
type &mut JNIEnv
in order to call into Java.