小编Arn*_*mar的帖子

Arrays.hashcode(int[]) 为不同元素提供相同的哈希值

我正在尝试根据数组中的整数计算哈希值。我期望具有不同整数的数组不具有相同的哈希码:

给定 [72, 99] 并执行 Arrays.hashcode([72,99]) 我得到 3292

给定 [73, 68] 并执行 Arrays.hashcode([73, 68]) 我也得到 3292

有人知道为什么会发生这种情况并且有替代我想要实现的目标吗?

java

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

解码十六进制:这行是做什么的(len&0x01)!= 0

我正在浏览Apache commons库中的一段代码,并想知道这些条件究竟是做什么的.

public static byte[] decodeHex(final char[] data) throws DecoderException {

        final int len = data.length;

        if ((len & 0x01) != 0) { // what does this condition do
            throw new DecoderException("Odd number of characters.");
        }

        final byte[] out = new byte[len >> 1];

        // two characters form the hex value.
        for (int i = 0, j = 0; j < len; i++) {
            int f = toDigit(data[j], j) << 4;
            j++;
            f = f | toDigit(data[j], j);
            j++;
            out[i] …
Run Code Online (Sandbox Code Playgroud)

java

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

使用模板参数将函数传递给Angular指令

嗨我在模板中使用参数时遇到问题,因为我已经将一个函数传递给了一个带有隔离范围的指令.该指令使用我调用函数的模板,但由于某种原因我的参数"meetpunt"是未定义的:

调试getCoordinaten函数时,我的模板,其中meetpunt似乎未定义:

 <tr ng-repeat="meetpunt in meetpunten">
     <td>{{getCoordinaten(meetpunt)}}</td>
 </tr>
Run Code Online (Sandbox Code Playgroud)

我的指示:

angular.module('zendantennesApp').directive('meetpuntTabel', function() {
    return {
        restrict: 'E',
        templateUrl: 'views/components/meetpunt-tabel/meetpunt-tabel.html',
        scope: {
            single: '@',
            meetpunten: '=',
            getCoordinaten: '&'
        },
        link: function(scope, element, attrs) {
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

我的控制器:

'use strict';

angular.module('zendantennesApp')
    .controller('MeetpuntTabelCtrl', function ($scope) {


        $scope.getCoordinaten = function (meetpunt) {
            return '(' + meetpunt.geometry.coordinates[0] + ', ' + meetpunt.geometry.coordinates[1] + ')';
        };


    });
Run Code Online (Sandbox Code Playgroud)

这就是我调用指令的方式:

<section ng-controller='MeetpuntTabelCtrl'><meetpunt-tabel meetpunten='meetpunten' get-coordinaten='getCoordinaten(meetpunt)' single='true'></meetpunt-tabel></section>
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.亲切的问候

angularjs

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

标签 统计

java ×2

angularjs ×1