小编Tim*_*sen的帖子

是否可以评论评论

评论时我有这种不便.但我想知道你们会怎么做.假设您有以下代码:

/*Fancy function*/
function fancyFunction(){
 echo "Oh yeah"
 //200 more lines go here
}
Run Code Online (Sandbox Code Playgroud)

现在我想评论整个功能,你会这样做:

/*

/*Fancy function*/             <--Comment breaks here
function fancyFunction(){
 echo "Oh yeah"
 //200 more lines go here
}
*/
Run Code Online (Sandbox Code Playgroud)

你是怎么做这个xD的

php commenting

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

傅里叶变换舍入误差

我正在搞乱傅立叶变换.现在我已经创建了一个实现DFT实现的类(没有像FFT atm这样做).这是我用过的实现:

public static Complex[] Dft(double[] data)
    {
        int length = data.Length;
        Complex[] result = new Complex[length];

        for (int k = 1; k <= length; k++)
        {
            Complex c = Complex.Zero;
            for (int n = 1; n <= length; n++)
            {
                c += Complex.FromPolarCoordinates(data[n-1], (-2 * Math.PI * n * k) / length);
            }
            result[k-1] =  1 / Math.Sqrt(length) * c;
        }
        return result;
    }
Run Code Online (Sandbox Code Playgroud)

这些是我得到的结果 Dft({2,3,4})

替代文字

好吧,看起来还不错,因为那些是我期望的值.我发现只有一件事令人困惑.这一切都与双打的四舍五入有关.

首先,为什么前两个数字不完全相同(0,8660..443 8)vs(0,8660..443).为什么它不能计算零,你期望它.我知道2.8E-15非常接近于零,但事实并非如此.

任何人都知道这些,边缘的错误是如何发生的,如果我能够并且想要对它做些什么.

似乎没有真正的问题,因为它只是小错误.但是,如果您要比较2个值,那么如何处理这些舍入误差.

5,2 + 0i != 5,1961524 …
Run Code Online (Sandbox Code Playgroud)

c# floating-point double fft

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

这里使用什么集合

我想知道我应该为此目的使用什么集合:

要求

  1. 必须包含元组 <value1,value2>
  2. 这些值之间没有关系(没有键值对)
  3. 只能包含唯一的元组
  4. <value1,value2> 等于 <value2,value1>

这里最好用什么?

java collections

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

简单的手机正则表达式

我想要一个检查以下内容的正则表达式:

  1. 该字符串以+开头
  2. '+'之后只能出现数字
  3. +之后应至少有4个数字

有谁知道如何做到这一点?

regex phone-number

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

搜索数组中的数据(列表)

我有一个ArrayList包含Attributes

class Attribute{
  private int id;
  public string getID(){
    return this.id;
  }

  private string value;
  public string getValue(){
    return this.value;
  }

  //... more properties here...
}
Run Code Online (Sandbox Code Playgroud)

好吧,我用数百个属性填充了ArrayList.我想找到具有已定义ID的属性.我想做这样的事情:

ArrayList<Attribute> arr = new ArrayList<Attribute>();
fillList(arr); //Method that puts a lot of these Attributes in the list
arr.find(234); //Find the attribute with the ID 234;
Run Code Online (Sandbox Code Playgroud)

循环遍历ArrayList是唯一的解决方案.

java search arraylist

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

接口方法的成员有不同的类型

我有这个界面

public interface TestInterface
{
   [returntype] MethodHere();
}

public class test1 : TestInterface
{
   string MethodHere(){
      return "Bla";
   }
}

public class test2 : TestInterface
{
   int MethodHere(){
     return 2;
   }
}
Run Code Online (Sandbox Code Playgroud)

有没有办法让[returntype]动态?

c# types interface member

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

JQuery .hover有记忆

我使用以下简单代码制作下拉菜单:

jQuery("#navigation li").hover(
    function(){jQuery(this).children("ul").slideToggle("fast");}, 
    function(){jQuery(this).children("ul").slideToggle("fast");
});
Run Code Online (Sandbox Code Playgroud)

但是当我#naviagtion li多次快速悬停时,它会保持slideToggling相同的次数.你怎么阻止这样做.

我在代码中弄乱了某种标志(isSliding)以查看它是否正在切换但是当我使用它时它看起来真的很麻烦.(我在开始滑动之前设置了标志,并且在回调中我再次将标志设置为false.在我调用函数之前,我只是有一个if(isSliding)声明.

示例:http://jsfiddle.net/8KxCd/2/

jquery

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