当前位置: 首页>>代码示例>>Java>>正文


Java Pointer.allocateLongs方法代码示例

本文整理汇总了Java中org.bridj.Pointer.allocateLongs方法的典型用法代码示例。如果您正苦于以下问题:Java Pointer.allocateLongs方法的具体用法?Java Pointer.allocateLongs怎么用?Java Pointer.allocateLongs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bridj.Pointer的用法示例。


在下文中一共展示了Pointer.allocateLongs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSymbols

import org.bridj.Pointer; //导入方法依赖的package包/类
public List<Symbol> getSymbols(ShowType type) throws ClingoException {
    List<Symbol> result = null;

    // determine the number of (shown) symbols in the model    
    Pointer<SizeT> size = Pointer.allocateSizeT();
    handleError(LIB.clingo_model_symbols_size(pointer, type.getInt(), size), "Error reading size of symbols of the model");

    if (0 < size.getLong()) {
        // allocate required memory to hold all the symbols
        Pointer<Long> atoms = Pointer.allocateLongs(size.getLong());

        // retrieve the symbols in the model
        handleError(LIB.clingo_model_symbols(pointer, type.getInt(), atoms, size.getLong()), "Error read the model symbols");

        result = Symbol.list(atoms, size.getLong());
    }
    return result;
}
 
开发者ID:lorislab,项目名称:clingo4j,代码行数:19,代码来源:Model.java

示例2: getSignatures

import org.bridj.Pointer; //导入方法依赖的package包/类
public List<Signature> getSignatures() throws ClingoException {
    Pointer<SizeT> n = Pointer.allocateSizeT();
    handleError(LIB.clingo_symbolic_atoms_signatures_size(pointer, n), "Error reading the symbolic atoms signatures size!");
    Pointer<Long> signatures = Pointer.allocateLongs(n.getLong());
    handleError(LIB.clingo_symbolic_atoms_signatures(pointer, signatures, n.getLong()), "Error reading the symbolic atoms signatures!");
    return Signature.list(signatures, n.getLong());
}
 
开发者ID:lorislab,项目名称:clingo4j,代码行数:8,代码来源:SymbolicAtoms.java

示例3: getCost

import org.bridj.Pointer; //导入方法依赖的package包/类
public List<Long> getCost() throws ClingoException {
    Pointer<SizeT> n = Pointer.allocateSizeT();
    handleError(LIB.clingo_model_cost_size(pointer, n), "Error reading model cost size!");
    Pointer<Long> ret = Pointer.allocateLongs(n.getLong());
    handleError(LIB.clingo_model_cost(pointer, ret, n.getLong()), "Error reading the model cost!");
    return ret.asList();
}
 
开发者ID:lorislab,项目名称:clingo4j,代码行数:8,代码来源:Model.java

示例4: printModel

import org.bridj.Pointer; //导入方法依赖的package包/类
private static void printModel(Pointer<Pointer<clingo_control>> ctrl, Pointer<Pointer<clingo_model>> model) {
    
    Set<String> result = new HashSet<>(RESULTS);
    
    int show = (int) (clingo_show_type.clingo_show_type_shown.value);

    Pointer<SizeT> atoms_n = Pointer.allocateSizeT();

    // determine the number of (shown) symbols in the model                
    if (!LIB.clingo_model_symbols_size(model.get(), show, atoms_n)) {
        error(ctrl, "Error create symbol size");
    }

    // allocate required memory to hold all the symbols
    Pointer<Long> atoms = Pointer.allocateLongs(atoms_n.getLong());

    // retrieve the symbols in the model
    if (!LIB.clingo_model_symbols(model.get(), show, atoms, atoms_n.getLong())) {
        error(ctrl, "Error create symbol symbols");
    }

    System.out.println("Model: ");

    for (int i = 0; i < atoms_n.getLong(); i++) {

        Long atom = atoms.get(i);

        // determine size of the string representation of the next symbol in the model  
        Pointer<SizeT> size = Pointer.allocateSizeT();
        LIB.clingo_symbol_to_string_size(atom, size);

        // allocate required memory to hold the symbol's string
        Pointer<Byte> string = Pointer.allocateBytes(size.getLong());

        // retrieve the symbol's string          
        if (!LIB.clingo_symbol_to_string(atom, string, size.getLong())) {
            error(ctrl, "Error symbol to string");
        }
        String st = string.getCString();
        
        System.out.print(st);
        Assert.assertTrue("Atom " + st + " does not exists in the result set", result.remove(st));
        System.out.print(" -> ");

        Pointer<Pointer<Long>> arguments = Pointer.allocatePointer(Long.class);
        Pointer<SizeT> arguments_size = Pointer.allocateSizeT();
        LIB.clingo_symbol_arguments(atom, arguments, arguments_size);

        Pointer<Pointer<Byte>> name = Pointer.allocatePointer(Byte.class);
        LIB.clingo_symbol_name(atom, name);
        System.out.print("name=" + name.get().getCString());

        System.out.print(",args=[");
        Pointer<Integer> t = Pointer.allocateInt();
        for (int a = 0; a < arguments_size.getLong(); a++) {
            if (a > 0) {
                System.out.print(",");
            }
            LIB.clingo_symbol_number(arguments.get().get(a), t);
            System.out.print(t.get());
        }
        System.out.print("]");

        System.out.println();
    }
    
    Assert.assertTrue("Result set is not empty!", result.isEmpty());
}
 
开发者ID:lorislab,项目名称:clingo4j,代码行数:69,代码来源:ControlTest.java


注:本文中的org.bridj.Pointer.allocateLongs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。