<commit_before>package luxe.structural;

/**
    WIP
*/

import Map;

class OrderedMapIterator<K,V> {

    var map : OrderedMap<K,V>;
    var index : Int = 0;

    public inline function new(omap:OrderedMap<K,V>)
        map = omap;
    public inline function hasNext() : Bool
        return index < map._keys.length;
    public inline function next() : V
        return map.get( map._keys[index++] );

} //OrderedMapIterator

class OrderedMap<K, V> implements IMap<K, V> {

    var map:Map<K, V>;
    var idx = 0;

    @:allow(luxe.structural.OrderedMapIterator)
    var _keys:Array<K>;

    public inline function new(_map) {
       _keys = [];
       map = _map;
    }

    public inline function set(key:K, value:V) {
        if (!map.exists(key)) _keys.push(key);
        map[key] = value;
    }

    public inline function toString() {
        var _ret = ''; var _cnt = 0; var _len = _keys.length;
        for(k in _keys) _ret += '$k => ${map.get(k)}${(_cnt++<_len-1?", ":"")}';
        return '{$_ret}';
    }

    public inline function iterator()          return new OrderedMapIterator<K,V>(this);<commit_msg>structural; OrderedMap; make generic by default for now<commit_after>package luxe.structural;

/**
    WIP
*/

import Map;

@:generic
class OrderedMapIterator<K,V> {

    var map : OrderedMap<K,V>;
    var index : Int = 0;

    public inline function new(omap:OrderedMap<K,V>)
        map = omap;
    public inline function hasNext() : Bool
        return index < map._keys.length;
    public inline function next() : V
        return map.get( map._keys[index++] );

} //OrderedMapIterator

@:generic
class OrderedMap<K, V> implements IMap<K, V> {

    @:noCompletion public var map:Map<K, V>;
    var idx = 0;

    @:allow(luxe.structural.OrderedMapIterator)
    var _keys:Array<K>;

    public inline function new(_map) {
       _keys = [];
       map = _map;
    }

    public inline function set(key:K, value:V) {
        if (!map.exists(key)) _keys.push(key);
        map[key] = value;
    }

    public inline function toString() {
        var _ret = ''; var _cnt = 0; var _len = _keys.length;
        for(k in _keys) _ret += '$k => ${map.get(k)}${(_cnt++<_len-1?", ":"")}';
        return '{$_ret}';
    }

    public inline function iterator()          return new OrderedMapIterator<K,V>(this);
{'fraction_non_alphanumeric': 0.14741379310344827, 'fraction_numerical': 0.0034482758620689655, 'mean_word_length': 2.6724683544303796, 'pattern_counts': {'":': 2, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '335502', 'n_tokens_mistral': 806, 'n_tokens_neox': 772, 'n_words': 202}