Erosion

 The erosion operation works on boolean as well as scalar values.

 @param [Integer] n Size of erosion operator.

 @return [Node] Result of operation.
512255
def erode( n = 3 )
      filter = Hornetseye::lazy( *( [ n ] * dimension ) ) { 0 }
      table( filter ) { |a,b| a }.diagonal { |m,x| m.minor x }
    end
622514
def reject!
      if block_given?
        return_nil = true
        @data.each do |k, v|
          if yield(k, v)
            @data.delete(k)
            return_nil = false
          end
        end
        return return_nil ? nil : self
      else
        return self.data.reject!
      end
    end
92928
def last(from: nil, to: nil, &block)
      retval = nil

      each_with_depth(from: from, to: nil) do |line, depth, index|
        retval = line if block.call(line, depth, index)
      end

      retval
    end
342925
public static <N extends AbstractDTNode<?, ?, ?, N>> Iterator<N> leafIterator(N root) {
        return Iterators.filter(nodeIterator(root), AbstractDTNode::isLeaf);
    }
631177
function(n) {
    n = _.isInteger(n) ? n : 0

    return {
      x: n,
      y: n,
      data: _.map(_.range(n), function (num) {
        return [num]
      })
    }
  }
1335888
@Override
  protected boolean hasOverflow(N node) {
    if(node.isLeaf()) {
      return node.getNumEntries() == leafCapacity;
    }
    else {
      return node.getNumEntries() == dirCapacity;
    }
  }
746803
def each
      traverse do |node, position, stack|
        if node.is_leaf? && position < node.keys.size
          yield(node.keys[position], node.values[position])
        end
      end
    end
227945
def ancestors
      return to_enum(__callee__) unless block_given?
      node = self
      loop do
        node = node.parent
        yield node
      end
    end
837413
def drop(n, it, constructor=list):
    
    return constructor(itertools.islice(it,n,None))
65265
def trim(n)
      result = self
      while n > 0 && !result.empty?
        result = result.tail
        n -= 1
      end
      result
    end
1065168
def filter_float(n: Node, query: str) -> float:
    
    return _scalariter2item(n, query, float)
1220264
def erosion(mapfile, dilated):
    
    ll = mappyfile.find(mapfile["layers"], "name", "line")
    ll["status"] = "OFF"

    pl = mappyfile.find(mapfile["layers"], "name", "polygon")

    # make a deep copy of the polygon layer in the Map
    # so any modification are made to this layer only
    pl2 = deepcopy(pl)

    pl2["name"] = "newpolygon"       
    mapfile["layers"].append(pl2)

    dilated = dilated.buffer(-0.3)
    pl2["features"][0]["wkt"] = dilated.wkt

    style = pl["classes"][0]["styles"][0]
    style["color"] = "#999999"
    style["outlinecolor"] = "#b2b2b2"
400247
def bucket_keys_to_guarantee_result_set_size(self, bucket_key, N, tree_depth):
        

        if tree_depth == len(bucket_key):
            #print 'Returning leaf bucket key %s with %d vectors' % (self.bucket_key, self.vector_count)
            # This is a leaf so just return the bucket key (we reached the bucket leaf)
            return [self.bucket_key]

        # If not leaf, this is a subtree node.

        hash_char = bucket_key[tree_depth]
        if hash_char == '0':
            other_hash_char = '1'
        else:
            other_hash_char = '0'

        # Check if child has enough results
        if hash_char in self.childs:
            if self.childs[hash_char].vector_count < N:
                # If not combine buckets of both child subtrees
                listA = self.childs[hash_char].collect_all_bucket_keys()
                listB = self.childs[other_hash_char].collect_all_bucket_keys()
                return listA + listB
            else:
                # Child subtree has enough results, so call method on child
                return self.childs[hash_char].bucket_keys_to_guarantee_result_set_size(bucket_key, N, tree_depth+1)
        else:
            # That subtree is not existing, so just follow the other side
            return self.childs[other_hash_char].bucket_keys_to_guarantee_result_set_size(bucket_key, N, tree_depth+1)
1063198
private List<DefNode> flatten(List<DefNode> result, List<DefNode> nodes) {
        nodes.stream().forEach(n -> {
            flatten(result, n.getChildren());
            result.add(n);
        });
        return result;
    }
1319117
def prune
      return true if !@down.nil? && down.prune 
      return true if !@left.nil? && left.prune 
      return true if !@right.nil? && right.prune 
      return true unless @value.nil?
      up.down = nil if !up.nil? && left.nil? && right.nil?
      false
    end
234875
def map
      mask = 0

      @universe.each do |value, n|
        unless @mask[n].zero?
          value = yield(value)

          if m = @universe.fetch(value, false)
            mask |= (1 << m)
          else
            raise "universe does not contain element #{value.inspect}"
          end
        end
      end

      copy(:mask => mask)
    end
310295
@CheckReturnValue
  private FlowScope traverseReturn(Node n, FlowScope scope) {
    scope = traverseChildren(n, scope);

    Node retValue = n.getFirstChild();
    if (retValue != null) {
      JSType type = functionScope.getRootNode().getJSType();
      if (type != null) {
        FunctionType fnType = type.toMaybeFunctionType();
        if (fnType != null) {
          inferPropertyTypesToMatchConstraint(
              retValue.getJSType(), fnType.getReturnType());
        }
      }
    }
    return scope;
  }