add dict_iter_getCounts()

This commit is contained in:
Andy2 2011-11-18 21:10:17 -08:00
parent 21330af568
commit b86330c71f
2 changed files with 22 additions and 0 deletions

View file

@ -1400,6 +1400,26 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1wordCount
return result;
}
JNIEXPORT jintArray JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getCounts
(JNIEnv* env, jclass C, jint closure )
{
jintArray result = NULL;
DictIterData* data = (DictIterData*)closure;
if ( NULL != data ) {
DictIter iter;
dict_initIter( &iter, data->dict, 0, MAX_COLS_DICT );
LengthsArray lens;
if ( 0 < dict_countWords( &iter, &lens ) ) {
XP_ASSERT( sizeof(jint) == sizeof(lens.lens[0]) );
result = makeIntArray( env, VSIZE(lens.lens), (jint*)&lens.lens );
(*env)->DeleteLocalRef( env, result );
}
}
return result;
}
JNIEXPORT jobjectArray JNICALL
Java_org_eehouse_android_xw4_jni_XwJNI_dict_1iter_1getPrefixes
( JNIEnv* env, jclass C, jint closure )

View file

@ -237,12 +237,14 @@ public class XwJNI {
public static native int dict_getTileValue( int dictPtr, int tile );
// Dict iterator
public final static int MAX_COLS_DICT = 15; // from dictiter.h
public static native int dict_iter_init( byte[] dict, String path,
JNIUtils jniu );
public static native void dict_iter_setMinMax( int closure,
int min, int max );
public static native void dict_iter_destroy( int closure );
public static native int dict_iter_wordCount( int closure );
public static native int[] dict_iter_getCounts( int closure );
public static native String dict_iter_nthWord( int closure, int nn );
public static native String[] dict_iter_getPrefixes( int closure );
public static native int[] dict_iter_getIndices( int closure );