小编Jan*_*sen的帖子

用GWT编译时替换类

我发现需要在项目中使用String.format。但是,这在GWT中不起作用,我有使用GWT RegExp的替代产品。但是,我希望我的项目在使用不依赖于GWT的普通Swing接口时运行时不会出现错误。共享代码取决于String.format。问题是我不知道如何使GWT编译器使用与其他代码不同的类。我已经尝试在一个文件中完成所有操作,但是它不起作用,因为GWT无法处理NoClassDefFoundError异常,该异常用于检测classpath中缺少GWT的时间。

这是我当前的代码:

package testpackage.shared;

import com.google.gwt.regexp.shared.RegExp;
import com.google.gwt.regexp.shared.SplitResult;

public class Util {

  public static String format(final String format, final Object... args) {
    try {
      final RegExp regex = RegExp.compile("%[a-z]");
      final SplitResult split = regex.split(format);
      final StringBuffer msg = new StringBuffer();
      for (int pos = 0; pos < split.length() - 1; pos += 1) {
        msg.append(split.get(pos));
        msg.append(args[pos].toString());
      }
      msg.append(split.get(split.length() - 1));
      return msg.toString();
    } catch (NoClassDefFoundError ex)  {
      return String.format(format, args);
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

如何在类路径中不使用GWT的情况下在GWT和JRE上进行编译和运行?在为GWT和Swing / Sun JRE进行构建时,是否真的需要使Ant构建脚本将整个文件替换为另一个文件?

java ant gwt noclassdeffounderror

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

确定比较和交换指令列表是否将对长度为N的列表进行排序

假设我有一个长度为N的数组中的索引对列表.我想确定在执行后是否对任意排序的列表进行排序

for pair in pairs:
  if list_to_sort[pair.first] > list_to_sort[pair.second]:
    swap(
      element_a_index=pair.first,
      element_b_index=pair.second,
      list=list_to_sort
    )
Run Code Online (Sandbox Code Playgroud)

显然,我可以测试N元素列表的所有排列.有更快的方法吗?如果有,那是什么?这叫什么?它可证明是最快的解决方案吗?

sorting algorithm

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

转换unsigned int时,GCC如何使用fildll?

英特尔指令集参考声明(强调我的):

将有符号整数源操作数转换为双扩展精度浮点格式,并将该值压入FPU寄存器堆栈.源操作数可以是字,双字或四字整数.加载时没有舍入错误.源操作数的符号被保留.该指令的操作在非64位模式和64位模式下是相同的.

在这里你可以看到我的测试用例:

% cat stackoverflow.c       
float uint2float(unsigned int a) {
    return a;
}
% gcc -c stackoverflow.c    
% objdump -d stackoverflow.o

stackoverflow.o:     file format elf32-i386


Disassembly of section .text:

00000000 <uint2float>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   83 ec 08                sub    $0x8,%esp
   6:   8b 45 08                mov    0x8(%ebp),%eax
   9:   ba 00 00 00 00          mov    $0x0,%edx
   e:   89 45 f8                mov    %eax,-0x8(%ebp)
  11:   89 55 fc                mov    %edx,-0x4(%ebp)
  14:   df 6d f8                fildll …
Run Code Online (Sandbox Code Playgroud)

floating-point x86 assembly unsigned x87

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

Verilog中的连接似乎没有使用全宽

源代码:

module main();
wire [31:0] a = 32'b0;
wire [25:0] a_man = {1'b1, a[24:0]};
initial begin
$display("%b\n%b\n%b", {1'b1,a[24:0]}, a_man[25:0], a_man);
end
endmodule
Run Code Online (Sandbox Code Playgroud)

实际产量:

% iverilog dings.v && vvp a.out
10000000000000000000000000
1xxxxxxxxxxxxxxxxxxxxxxxxx
1xxxxxxxxxxxxxxxxxxxxxxxxx
Run Code Online (Sandbox Code Playgroud)

我不明白为什么a_man没有分配所有的比特.我不明白在串联内联和在线索声明中进行连接之间的区别.

verilog

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

如何在 Lean 中定义偏序集?

我想在精益定理证明器中证明这个定理。首先,我需要定义部分有序集合之类的东西,以便我可以定义 infimum/supremum。这在精益中是如何完成的?本教程提到了 setoids,它们是具有关联等价关系的类型。但我不清楚这有什么帮助。

set theorem-proving dependent-type lean

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

MFC 标头中的语法错误

我正在尝试编译 pgpfone,但我从 VS6 迁移到 VS2008,然后迁移到 VS2015 的构建系统有问题。

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /I.\ /I..\common /I..\bignum /I..\..\..\libs\pfl\win32 /I..\..\..\libs\pfl\common /I..\..\..\libs\pfl\common\util /ZI /nologo /W2 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _WINDOWS /D PGP_WIN32=1 /D PGPXFER=1 /D PGP_INTEL=1 /D BNINCLUDE=bni80386c.h /D _VC80_UPGRADE=0x0600 /Gm /EHsc /MTd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo".\Debug/" /Fd".\Debug/vc140.pdb" /Gd /TP /analyze- /errorReport:queue ..\common\ADPCM.cpp ..\common\blowfish.cpp ..\common\bytefifo.cpp ..\common\cast5.cpp ..\common\CControlThread.cpp ..\common\CCounterEncryptor.cpp ..\common\CEncryptionStream.cpp ..\common\CMessageQueue.cpp ..\common\CPFPackets.cpp ..\common\CPFTransport.cpp ..\common\CPipe.cpp ..\common\CPriorityQueue.cpp ..\common\crc.cpp ..\common\CSoundInput.cpp ..\common\CSoundOutput.cpp ..\common\CXferThread.cpp ..\common\des3.cpp ..\common\dh.cpp ..\common\DHPrimes.cpp ..\common\fastpool.cpp ..\common\HashWordList.cpp ..\common\PGPFoneUtils.cpp ..\common\samplerate.cpp ..\common\SHA.cpp …
Run Code Online (Sandbox Code Playgroud)

c++ mfc visual-c++

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