问题列表 - 第38076页

列表与ArrayList作为参考类型?

好的,所以我知道Set,List并且Map是接口,但是什么使得第一行代码比第二行更好?

List myArr = new ArrayList();
ArrayList myArr = new ArrayList();
Run Code Online (Sandbox Code Playgroud)

java interface list arraylist

22
推荐指数
3
解决办法
7798
查看次数

简单C代码(指针)出错

在下面的代码中,使用libxml库:

key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1);
                if (flag == 1)
                {
                        image2 = key;
                        printf("the image 2 is %s \n", image2);
                        flag = 2;
                }
                if(flag == 0)
                {
                        image1 = key;
                        printf("the image 1 is %s \n", image1);
                        flag = 1;
                }
                    //printf("SRC of the file is: %s\n", key);

                xmlFree(key);
            printf("the image 1 is %s \n", image1);
Run Code Online (Sandbox Code Playgroud)

两个printf给了我不同的输出.

输出是:

the image 1 is 1.png 
the image 1 is 0p?  g 
the image 2 is 2.png 
the image 1 is …
Run Code Online (Sandbox Code Playgroud)

c pointers

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

字符串转换

我有一个长字符串对象,其格式如下

myString = “[name = john, family = candy, age = 72],[ name = jeff, family = Thomson, age = 24]”
Run Code Online (Sandbox Code Playgroud)

当然字符串比这长.我还有3个相关名单:

Names    = []
Families = []
Ages     = []
Run Code Online (Sandbox Code Playgroud)

我希望逐个字符地读取该字符串并获取数据并将其附加到适当的列表中.任何人都可以帮我解决如何将字符串分成变量的问题吗?我需要的是这样的事情:

Names = [“john”, “jeff”, ...]
Families = [“candy”, “Thomson”, ...]
Ages = [72, 24, ...]
Run Code Online (Sandbox Code Playgroud)

python string

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

Greasemonkey的LocalStorage

我已经开始编写一个greasemonkey脚本,并且遇到了在Greasemonkey脚本中执行localstorage的问题.我可以在GM中找出localstorage的唯一方法是在newElement.innerHTMLDOM属性中创建另一个Javascript实例,但其余的变量都是不可访问的.

有任何想法吗 ?这是我正在研究的Greasemonkey代码片段.

        var testHref = anchorTag[i].href;
    var testHTML = anchorTag[i].innerHTML;
    var patHref = /item\?id=[0-9]*/g;
    var patCaptureId = /item\?id=([0-9]*)/g;
    var testId = patCaptureId.exec(testHref);
    var patHTML = /[0-9]* comment(|s)/g;
    var patHTML2 = /discuss/g;
    if(patHref.test(testHref) && !patHTML.test(testHTML) && !patHTML2.test(testHTML))
    {
        newElement = document.createElement('span');
        newElement.style.color = "#FF0000";
        newElement.innerHTML = "<a href=\"javascript:localStorage.setItem( 'one', 'rishabhVerma' ); var test = localStorage.getItem( 'one' ); console.log( test );\"> B</a>";
        anchorTag[i].parentNode.insertBefore(newElement, anchorTag[i].nextSibling); 
    }
    i++;
Run Code Online (Sandbox Code Playgroud)

javascript greasemonkey local-storage google-chrome-extension

9
推荐指数
2
解决办法
7486
查看次数

StructureMap - 如何注册和解析开放泛型类型

public interface IRepository<T> where T : Entity
{
    void Delete(T entity);
    T[] GetAll();
    T GetById(int id);
    void SaveOrUpdate(T enity);
    void Merge(T entity);
}

public interface ITeamEmployeeRepository : IRepository<TeamEmployee>
{
    PagedList<TeamEmployee> GetPagedTeamEmployees(int pageIndex, int pageSize);
}


public class Repository<T> : IRepository<T> where T : Entity
{
    private readonly ISession _session;

    protected Repository()
    {
        _session = GetSession();
    }

    public virtual void Delete(T entity)
    {
        _session.Delete(entity);
    }

    public virtual T[] GetAll()
    {
        return _session.CreateCriteria<T>().List<T>().ToArray();
    }

    public virtual T GetById(int id)
    {
        return _session.Get<T>(id); …
Run Code Online (Sandbox Code Playgroud)

c# structuremap repository ioc-container

8
推荐指数
2
解决办法
5261
查看次数

可能在ReadFile()上有超时?

while(GetExitCodeProcess(processInfo.hProcess, &exitCode)
        && exitCode == STILL_ACTIVE)
{
    ReadFile(defaultSTDIN, chBuf, 1, &dwRead, 0);
    WriteFile(writingEnd, chBuf, 1, &dwWritten, 0);
}
Run Code Online (Sandbox Code Playgroud)

上面代码的问题是,即使通过processInfo.hProcess引用的子进程已经退出,我们仍然停留在while循环中,因为ReadFile()正在等待输入.什么是解决这个问题的最佳方法?

c++ windows

7
推荐指数
2
解决办法
8475
查看次数

OpenGLES中的glPolygonMode

在OpenGL ES中是否有与glPolygonMode相同的功能?如何在OpenGL ES中渲染线框?

opengl-es

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

MongoDB:按日期查询

在MongoDB数据库中,我有一组项目,每个项目都存储其创建日期.我需要按日期查询此集合.我试过了:

db.items.findOne({date:{new Date(1285947037*1000)}})

但它没有返回任何东西.我使用PHP获得了时间戳($date->sec其中$dateMongoDate数据库中的对象).那么这样做的正确方法是什么?谢谢.

php mongodb

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

可以从iPhone的麦克风测量什么范围的声音频率?

我想知道iPhone麦克风可以听的频率范围,我们可以播放iPhone麦克风录制的最低频率声音吗?

iphone microphone frequency range voice-recording

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

SQL Server Express - 商业用途

我正在开发一个网站,我想使用SQL Server Express作为我的数据库.Express版本每个数据库限制为4GB.

使用单个网站创建和使用多个数据库是否合法?

database sql-server

9
推荐指数
2
解决办法
1601
查看次数