问题列表 - 第26101页

如何使内部类不可实现?

我想要一个静态内部类,即使是外部类也无法实例化.现在我只有一个文档说"请不要实例化这个对象".我可以给出更好的信号吗?

java class inner-classes

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

在iTunes上搜索曲目

我想在Mac OS/X上使用Python脚本在iTunes 上搜索曲目.我找到了通过以下方式访问iTunes应用程序的方法:

iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")

但我还没有想出(还)执行搜索的方式.一点帮助赞赏.

免责声明:OS/X新手在这里.

注意:我不是在寻找直接访问XML/plist数据库的方法.

python macos scripting itunes

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

有没有办法通过Java中的Reflection获取InnerClasses列表?

有没有办法通过Java中的Reflection知道类具有的内部类?

java reflection

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

F#在科学计算中的表现

我很好奇F#性能与C++性能的对比情况如何?我问了一个关于Java的类似问题,我得到的印象是Java不适合重编码.

我已经读过F#应该具有更高的可扩展性和更高的性能,但这种真实性能与C++相比如何呢?关于当前实施的具体问题是:

  • 浮点数有多好?
  • 它是否允许矢量指令
  • 对优化编译器有多友好?
  • 它有多大的记忆足迹?它是否允许对内存位置进行细粒度控制?
  • 它是否具有分布式内存处理器的容量,例如Cray?
  • 在涉及大量处理的计算科学中,它可能具有哪些特征?
  • 是否有使用它的实际科学计算实现?

谢谢

c++ parallel-processing performance f# scientific-computing

71
推荐指数
6
解决办法
2万
查看次数

ActiveRecord中的随机记录

我需要通过ActiveRecord从表中获取随机记录.我从2006年开始跟随Jamis Buck的例子.

但是,我也通过Google搜索遇到了另一种方式(由于新的用户限制,无法使用链接进行归因):

 rand_id = rand(Model.count)
 rand_record = Model.first(:conditions => ["id >= ?", rand_id])
Run Code Online (Sandbox Code Playgroud)

我很好奇这里的其他人是如何做到的,或者是否有人知道哪种方式会更有效率.

random ruby-on-rails rails-activerecord

147
推荐指数
11
解决办法
8万
查看次数

为什么我不能使用速记为类分配标量值,而是首先声明它,然后设置它的值?

我正在为C++编写一个UTF-8库作为练习,因为这是我的第一个真实的C++代码.到目前为止,我已经在名为"ustring"的类中实现了串联,字符索引,解析和编码UTF-8.它看起来很有效,但两种看似相同的声明新ustring的方式表现不同.第一种方式:

ustring a;
a = "test";
Run Code Online (Sandbox Code Playgroud)

工作,并且重载的"="运算符将字符串解析为类(将Unicode字符串存储为动态分配的int指针).但是,以下不起作用:

ustring a = "test";
Run Code Online (Sandbox Code Playgroud)

因为我收到以下错误:

test.cpp:4: error: conversion from ‘const char [5]’ to non-scalar type ‘ustring’ requested
Run Code Online (Sandbox Code Playgroud)

有没有办法解决这个错误?但是,我的代码可能存在问题.以下是我到目前为止为图书馆写的内容:

#include <cstdlib>
#include <cstring>
class ustring {
  int * values;
  long len;
  public:
  long length() {
    return len;
  }
  ustring * operator=(ustring input) {
    len = input.len;
    values = (int *) malloc(sizeof(int) * len);
    for (long i = 0; i < len; i++)
      values[i] = input.values[i];
    return this;
  }
  ustring * operator=(char input[]) {
    len …
Run Code Online (Sandbox Code Playgroud)

c++ overloading class utf-8

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

我不小心创建了一个名为-track的git本地分支,如何删除它?

我输入了一个git命令,导致创建了一个名为'--track'的本地分支.

我尝试过以下方法:

git branch -m --track delme
(this renames the current branch to delme, not the branch called --track)

git checkout --track
> fatal: --track needs a branch name

git branch -d --track
(does nothing, reports nothing)

git branch -D --track
(also does nothing)

git branch -d "--track"
(also does nothing
Run Code Online (Sandbox Code Playgroud)

我该如何删除这个分支?

git

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

使用变换旋转,然后更改帧原点,视图是否展开?

这完全是iPhone的庸俗.我正在开发一个库,但已将我的问题缩小到非常简单的代码.这段代码的作用是创建一个50x50的视图,应用几度的旋转变换,然后将帧向下移动几次.结果是50x50视图现在看起来更大.

这是代码:

// a simple 50x50 view
UIView *redThing = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 50, 50)];
redThing.backgroundColor = [UIColor redColor];

[self.view addSubview:redThing];

// rotate a small amount (as long as it's not 90 or 180, etc.)
redThing.transform = CGAffineTransformRotate(redThing.transform, 0.1234);

// move the view down 2 pixels
CGRect newFrame = CGRectMake(redThing.frame.origin.x, redThing.frame.origin.y + 2, redThing.frame.size.width, redThing.frame.size.height);
redThing.frame = newFrame;

// move the view down another 2 pixels
newFrame = CGRectMake(redThing.frame.origin.x, redThing.frame.origin.y + 2, redThing.frame.size.width, redThing.frame.size.height);
redThing.frame = newFrame;

// move …
Run Code Online (Sandbox Code Playgroud)

iphone animation quartz-graphics

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

从Java连接到HTTPS服务器并忽略安全证书的有效性

我一直在测试一个系统,该系统访问一组具有不同密钥的https服务器,其中一些密钥无效,并且所有密钥都不在我的JVM的本地密钥存储区中.我真的只是测试一下,所以我不关心现阶段的安全性.有没有一种方法可以对服务器进行POST调用,并告诉Java不要担心安全证书?

我的谷歌搜索这个已经提出了一些代码示例,使一个类进行验证,这总是有效,但我不能让它连接到任何服务器.

java security ssl https

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

可以在Windows上使用Grand Central Dispatch(`libdispatch`)吗?

我期待到多线程,和GCD似乎是一个很大比使用手工编写的解决方案更好的选择pthread.hpthreads-win32.然而,虽然看起来libdispatch要么正在开发,要么很快就要开始工作,大多数新的POSIX兼容系统......我不得不问,Windows呢?libdispatch移植到Windows 的可能性有多大?阻止这种情况发生的障碍是什么?

如果它归结为它,需要做什么来预成型portage?

编辑:我已经知道的一些事情,以便开始讨论:

  • 我们需要一个可以在Windows上编译的块兼容编译器,不是吗?将PLBlocks处理这个问题?
  • 我们可以使用LLVM 块运行时吗?
  • 为了便携性,我们不能用APR调用替换pthread.h用户空间中的所有依赖项libdispatch吗?或者,或者,使用pthreads-win32我想...

编辑1:我听说这是完全和完全不可能的,因为libdispatch依赖(某种程度上)kqueue,在Windows上无法提供...有人知道这是真的吗?

windows multithreading portability libdispatch grand-central-dispatch

16
推荐指数
3
解决办法
4687
查看次数