小编mar*_*who的帖子

反向数组顺序

我试图扭转java中数组的顺序.
在O(n)中使用最少内存量的最有效方法是什么.
无需用代码回答,伪代码就行了.
这是我的思考过程:

  create a new temp array //I think this is a waste of memory, 
                          //but I am not sure if there's a better way
 grab elements from the end of the original array -decrement this variable
 insert element in beginning of temp array -increment this variable
then make the original array point to the temp array? //I am not sure 
            //if I can do this in java; so let's say the 
            //original array is Object[] arr; and …
Run Code Online (Sandbox Code Playgroud)

java arrays reverse

19
推荐指数
3
解决办法
7万
查看次数

Android注册安全提供程序

我试图了解java安全提供程序如何在android中工作.我想强制所有对Cipher.getInstance()的调用返回一个带有海绵城堡作为提供者的密码.我没有运气.

以下代码返回一个提供者为"AndroidKeyStoreBCWorkaround版本1.0"的密码,但我希望提供者为SpongyCastle.

我想这样做的原因是,我有一个多次调用javax.crypto.Cipher.getInstance()的库.我希望所有这些调用都能进入海绵城堡,而不必重新编写库以明确指定"SC"作为提供者.

public class MainActivity extends Activity
{
    static
    {
        Security.insertProviderAt(new org.spongycastle.jce.provider.BouncyCastleProvider(), 1);
        Security.removeProvider("BC");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        try
        {
          //this returns provider = "AndroidKeyStoreBCWorkaround version 1.0"
          javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance("AES/CTR/NoPadding");
          //this works
          // cipher = javax.crypto.Cipher.getInstance("AES/CTR/NoPadding", "SC");
        }
        catch(Exception e)
        {
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

java security encryption android

9
推荐指数
1
解决办法
1506
查看次数

扩展枚举类型

可能重复:
在C++中扩展枚举?

我正在使用一个库,它将自己的错误集定义为枚举类型.

枚举error_type {...}

该库还有一个函数,它接受枚举类型,并打印错误.

void set_status(error_type new_error)

如果我想定义自己的错误,并将其提供给set_status函数,是否有可能以某种方式扩展error_type枚举,或者可能覆盖它?

c++ enums

4
推荐指数
1
解决办法
3439
查看次数

命名空间'boost'中的'mutex'没有命名类型

我尝试编译以下代码时收到此错误:

#include <boost/signals2/mutex.hpp>

class Log
{
    private:
        boost::mutex m_log;
...
}
Run Code Online (Sandbox Code Playgroud)

我尝试编译时得到的错误是:

error: ‘mutex’ in namespace ‘boost’ does not name a type
Run Code Online (Sandbox Code Playgroud)

c++

2
推荐指数
1
解决办法
3149
查看次数

连续排序数组

我有一个用户给我一个随机数组的对象,我想做一些错误检查,基本上我希望空对象在数组的末尾,以便数组的中间只由非null组成对象(对象的排序无关紧要).

这是我拥有的,它不起作用.谁能请帮忙.

private void properArray(){
    int i = 0;
    int j;
    int cap = theHeap.length;
    for(; i < (cap-1); i++){
        if (theHeap[i] == null){
            j = i + 1;
            while(j < (cap-1)){
                if(theHeap[j] != null){
                    theHeap[i] = theHeap[j];
                    theHeap[j] = null;
                }
                j++;  
            }
        }
    } 
}
Run Code Online (Sandbox Code Playgroud)

java arrays sorting object

1
推荐指数
1
解决办法
198
查看次数

oracle中的SQL查询展平了一个表

所以我在sql中有一个表,它看起来像这样

controlnum  taxyear        payrollg                 alaska
12334        2012           16                      25
12334        2012           16                      25
12334        2012           16                      NULL
12334        2012           16                      NULL
12334        2012           16                      25
12334        2012           16                      25
12332        2012           14                      23
12332        2012           14                      NULL
12333        2012           14                      23
12333        2012           14                      NULL
Run Code Online (Sandbox Code Playgroud)

我想这样压扁它

controlnum  taxyear        payroll                 alaska
12334        2012           16                      25
12333        2012           14                      23
12332        2012           14                      23
Run Code Online (Sandbox Code Playgroud)

这是我试过的查询,它给了我语法错误,任何人都可以帮忙吗?

SELECT 
Controlnum "controlNumber",
taxyear "taxYear",
payrollg "payRollGroup"

FROM 
states

MAX (CASE WHEN alaska IS NOT NULL THEN …
Run Code Online (Sandbox Code Playgroud)

sql oracle oracle11g

1
推荐指数
1
解决办法
1243
查看次数

C++指针麻烦

我遇到以下代码的问题.我是一名java开发人员,试图自学c ++.主要是我在main()中的代码没有向根节点插入任何内容.谁能帮我.我确信我的指针还有一些东西.

class Node{
    public:
        Node* left;
        Node* right;
        int data;

    Node(int n){
        data = n;
        right = NULL;
        left = NULL;
    }
};

class BST{

    Node* root;

    public:

    BST(){
        root = NULL;
    }

    void insert(int e){
        pinsert(root, e);
    }

    void pinsert(Node* sr, int e){
        if(sr == NULL){
            sr = new Node(e);
        }
        else{
            if((sr->data) > e ){
                pinsert(sr->left, e);
            }
            else{
                pinsert(sr->right, e);
            }
        }
    }
};


int main(){
    BST tree;
    tree.insert(6);
    tree.insert(7);
}
Run Code Online (Sandbox Code Playgroud)

c++ pointers

0
推荐指数
1
解决办法
114
查看次数

标签 统计

c++ ×3

java ×3

arrays ×2

android ×1

encryption ×1

enums ×1

object ×1

oracle ×1

oracle11g ×1

pointers ×1

reverse ×1

security ×1

sorting ×1

sql ×1