| 416 | } |
| 417 | |
| 418 | @StarlarkMethod( |
| 419 | name = "keys", |
| 420 | doc = |
| 421 | "Returns the list of keys:" |
| 422 | + "<pre class=\"language-python\">{2: \"a\", 4: \"b\", 1: \"c\"}.keys() == [2, 4, 1]" |
| 423 | + "</pre>\n", |
| 424 | useStarlarkThread = true) |
| 425 | public StarlarkList<?> keys(StarlarkThread thread) throws EvalException { |
| 426 | Object[] array = new Object[size()]; |
| 427 | int i = 0; |
| 428 | for (K e : contents.keySet()) { |
| 429 | array[i++] = e; |
| 430 | } |
| 431 | return StarlarkList.wrap(thread.mutability(), array); |
| 432 | } |
| 433 | |
| 434 | private static final Dict<?, ?> EMPTY = new Dict<>(ImmutableMap.of()); |
| 435 | |