Exemplo n.º 1
0
    def test_java_object_arrays(self):
        jStringArr = array(String, [String("a"), String("b"), String("c")])
        self.assert_(
            Arrays.equals(jStringArr.typecode, 'java.lang.String'),
               "String array typecode of wrong type, expected %s, found %s" % 
               (jStringArr.typecode, str(String)))
        self.assertEqual(zeros(String, 5), Array.newInstance(String, 5))

        import java.lang.String # require for eval to work
        self.assertEqual(jStringArr, eval(str(jStringArr)))
Exemplo n.º 2
0
def test_java_object_arrays():
   jStringArr = array(String, [String("a"), String("b"), String("c")])
   verify(Arrays.equals(jStringArr.typecode, str(String)), 
         "String array typecode of wrong type, expected %s, found %s" % 
         (jStringArr.typecode, str(String)))
   verify(zeros(String, 5) == Array.newInstance(String, 5))

   import java # require for eval to work
   if jStringArr != eval(str(jStringArr)):
      raise TestFailed, "eval(str(%s)) <> %s" % (jStringArr,)*2
Exemplo n.º 3
0
    def test_java_object_arrays(self):
        jStringArr = array(String, [String("a"), String("b"), String("c")])
        self.assert_(
            Arrays.equals(jStringArr.typecode, 'java.lang.String'),
            "String array typecode of wrong type, expected %s, found %s" %
            (jStringArr.typecode, str(String)))
        self.assertEqual(zeros(String, 5), Array.newInstance(String, 5))

        import java.lang.String  # require for eval to work
        self.assertEqual(jStringArr, eval(str(jStringArr)))
Exemplo n.º 4
0
    private int row;
    private int col;
    public boolean hasPath(int[][] maze, int[] start, int[] destination) {
        // write your code here
        if(maze.length == 0 || maze[0].length == 0 || start.length == 0 || destination.length == 0) {
            return false;
        }
        row = maze.length;
        col = maze[0].length;
        visited = new int[row][col];
        
        return dfs(maze, start, destination);
    }
    
    public boolean dfs(int[][] maze, int[] start, int[] destination) {
        if(Arrays.equals(start, destination)) {
            return true;
        }

        if(visited[start[0]][start[1]] == 1) {
            return false;
        }
        visited[start[0]][start[1]] = 1;
        for (int i = 0; i < 4; i++) {
            int x = start[0];
            int y = start[1];
            while(x > -1 && x < row && y > -1 && y < col && maze[x][y] == 0) {
                x += direction[i][0];
                y += direction[i][1];
            }
            
Exemplo n.º 5
0
 def consolidateDuplicateIssues(self, isb, isa):
     if Arrays.equals(isb.getHttpMessages()[0].getResponse(),
                      isa.getHttpMessages()[0].getResponse()):
         return -1
     else:
         return 0
Exemplo n.º 6
0
from java.util import Arrays as A

l = [x for x in range(10)]
print (l)
l.sort()
print (A.binarySearch(l,3))
k = [1,2,3,4,5,6,7,8,9,0]
print (A.equals(l,k))
print (A.copyOf(l,len(l)))