basic implementation of Java-like keySet().
The method returns an array containing the node keys.

TODO return (java like generic) set object

@return array
322911
public function keySet(): array {
        $keySet = [];
        /** @var SinglyLinkedList $list */
        foreach ($this->bucket as $list) {
            if (null === $list) {
                continue;
            }
            /** @var Node $head */
            $head = $list->getHead();
            while ($head !== null) {
                $keySet[] = $head->getKey();
                $head = $head->getNext();
            }
        }
        return $keySet;
    }
1081055
private void printKeySet() {
    Set<?> keys = keySet();
    System.out.println("printing keyset:");
    for (Object o: keys) {
      //System.out.println(Arrays.asList((Object[]) i.next()));
      System.out.println(o);
    }
  }
331158
@SuppressWarnings("unchecked")
    public Object getThirdKeyPart() {
        Object keyPart = null;
        if (this.key.value() instanceof List && ((List<Object>) this.key.value()).size() > 1) {
            keyPart = ((List<Object>) this.key.value()).get(2);
        }
        return keyPart;
    }
772325
public byte[] getKeySetToByteArray() 
    {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(baos);
        
        char[] buffer = new char[getMaxFieldLenth()];
        
        try
        {
            for ( String s : keys )
            {
                Arrays.fill(buffer, (char)0);
                System.arraycopy( s.toCharArray(), 0, buffer, 0, s.length() );
                dos.writeBytes( new String(buffer) );
            }
        }
        catch  (IOException e)
        {
            System.err.println("Could not write Structure key set to byte array: " + e );
            return new byte[0];
        }
        return baos.toByteArray();
        
    }
368850
@SuppressWarnings("unchecked")
    public Iterator<K> keys()
    {
        int size = _size;

        if (size == 0)
        {
            return null;
        }
        ArrayList<K> keyList = new ArrayList<K>();
        int i = (size - 1) * 2;
        while (i >= 0)
        {
            keyList.add((K) _array[i]);
            i = i - 2;
        }
        return keyList.iterator();
    }
220038
public function toArray()
    {
        $data = parent::toArray();

        foreach(array_keys($data) as $key)
        {
            if (substr($key, 0, 1) === '_') {
                unset($data[$key]);
            }
        }

        return $data;
    }
314590
public function mget($keys)
	{
	    $res = [];
	    if (is_array($keys)) {
	        foreach ($keys as $k) {
	            $res[$k] = $this->get($k);
	        }
	    } else {
	        $res[$keys] = $this->get($keys);
	    }
	    
	    return $res;
	}
1268440
public byte[] getAsByteArray(String key) {
        Object value = mValues.get(key);
        if (value instanceof byte[]) {
            return (byte[]) value;
        } else {
            return new byte[]{};
        }
    }

    /**
     * Returns a set of all of the keys and values
     *
     * @return a set of all of the keys and values
     */
    public Set<Map.Entry<String, Object>> valueSet() {
        return mValues.entrySet();
    }

    /**
     * Returns a set of all of the keys
     *
     * @return a set of all of the keys
     */
    public Set<String> keySet() {
        return mValues.keySet();
    }


    public int describeContents() {
        return 0;
    }

    /**
     * Returns a string containing a concise, human-readable description of this object.
     * @return a printable representation of this object.
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        for (String name : mValues.keySet()) {
            String value = getAsString(name);
            if (sb.length() > 0) sb.append(" ");
            sb.append(name + "=" + value);
        }
        return sb.toString();
    }
248416
protected String[] getKeysFromResultSet() throws SQLException {

        String[] keys;
        final ResultSetMetaData md = _resultSet.getMetaData();
        final int columnCount = md.getColumnCount();

        keys = new String[columnCount + 1];
        for (int i = 1; i <= columnCount; i++) {
            keys[i] = md.getColumnName(i).toUpperCase();
        }
        return keys;
    }
851472
public Set<List<K>> keySet() {
    return ErasureUtils.<Set<List<K>>>uncheckedCast(keySet(new HashSet<Object>(), zeroKey, true));
  }
1121815
@SuppressWarnings("deprecation") // The String ctor is deprecated, but fast.
  public Set<String> keys() {
    if (isEmpty()) {
      return Collections.emptySet();
    }
    Set<String> ks = new HashSet<>(size);
    for (int i = 0; i < size; i++) {
      ks.add(new String(name(i), 0 /* hibyte */));
    }
    // immutable in case we decide to change the implementation later.
    return Collections.unmodifiableSet(ks);
  }
566204
@SuppressWarnings("unchecked")
    public <T> T[] toArray(Set<T> set) {
	    if (set == null) {
	        return null;
	    }
	    
		return (T[]) set.toArray(new Object[set.size()]);
	}
801167
public function keys()
    {
        $found = [];

        foreach ($this->findExpressions(['class' => KeyExpression::class]) as $expression) {
            // Make them unique
            $found["$expression"] = $expression;
        }

        return new StringList(array_keys($found));
    }
671243
public function keys()
    {
        $map = new Map;
        foreach (array_keys($this->array) as $hash) {
            $map[] = $this->hash_to_key($hash);
        }
        return $map;
    }
1158326
public Iterator<K> keys()
  {
    KeyIterator<K,V> iter = new KeyIterator<K,V>(this);

    iter.init(this);

    return iter;
  }
812499
public function toASN1(): Set
    {
        $elements = array_map(
            function (AttributeTypeAndValue $tv) {
                return $tv->toASN1();
            }, $this->_attribs);
        $set = new Set(...$elements);
        return $set->sortedSetOf();
    }
137851
public function keys(): Set
    {
        $key = function($pair) {
            return $pair->key;
        };

        return new Set(array_map($key, $this->pairs));
    }