<commit_before>! Copyright (C) 2008 <NAME>, <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes deques dlists fry kernel
sequences sequences.private ;
IN: linked-assocs

TUPLE: linked-assoc { assoc read-only } { dlist dlist read-only } ;

: <linked-assoc> ( exemplar -- assoc )
    0 swap new-assoc <dlist> linked-assoc boa ;

: <linked-hash> ( -- assoc )
    H{ } <linked-assoc> ;

M: linked-assoc assoc-size assoc>> assoc-size ;

M: linked-assoc at*
    assoc>> at* [ [ obj>> second-unsafe ] when ] keep ;

<PRIVATE

: (delete-at) ( key assoc dlist -- )
    '[ at [ _ delete-node ] when* ] [ delete-at ] 2bi ; inline

PRIVATE>

M: linked-assoc delete-at
    [ assoc>> ] [ dlist>> ] bi (delete-at) ;

<PRIVATE

: add-to-dlist ( value key dlist -- node )
    [ swap 2array ] dip push-back* ; inline

PRIVATE>

M: linked-assoc set-at
    [ assoc>> ] [ dlist>> ] bi
    '[ _ 2over key? [ 3dup (delete-at) ] when nip add-to-dlist ]
    [ set-at ] 2bi ;

M: linked-assoc >alist
    dlist>> dlist>sequence ;

M: linked-assoc clear-assoc
    [ assoc>> clear-assoc ] [ dlist>> clear-deque ] bi ;

M: linked-assoc clone
    [ assoc>> clone ] [ dlist>> clone ] bi linked-assoc boa ;

: >linked-assoc ( assoc -- linked-assoc )
    >alist [ <linked-hash> ] dip assoc-union! ;

M: linked-assoc assoc-like
    drop dup linked-assoc? [ >linked-assoc ] unless ; inline

INSTANCE: linked-assoc assoc
<commit_msg>Revert "Temporary patch for assoc-map on linked-assoc"<commit_after>! Copyright (C) 2008 <NAME>, <NAME>.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes deques dlists fry kernel
sequences sequences.private ;
IN: linked-assocs

TUPLE: linked-assoc { assoc read-only } { dlist dlist read-only } ;

: <linked-assoc> ( exemplar -- assoc )
    0 swap new-assoc <dlist> linked-assoc boa ;

: <linked-hash> ( -- assoc )
    H{ } <linked-assoc> ;

M: linked-assoc assoc-size assoc>> assoc-size ;

M: linked-assoc at*
    assoc>> at* [ [ obj>> second-unsafe ] when ] keep ;

<PRIVATE

: (delete-at) ( key assoc dlist -- )
    '[ at [ _ delete-node ] when* ] [ delete-at ] 2bi ; inline

PRIVATE>

M: linked-assoc delete-at
    [ assoc>> ] [ dlist>> ] bi (delete-at) ;

<PRIVATE

: add-to-dlist ( value key dlist -- node )
    [ swap 2array ] dip push-back* ; inline

PRIVATE>

M: linked-assoc set-at
    [ assoc>> ] [ dlist>> ] bi
    '[ _ 2over key? [ 3dup (delete-at) ] when nip add-to-dlist ]
    [ set-at ] 2bi ;

M: linked-assoc >alist
    dlist>> dlist>sequence ;

M: linked-assoc clear-assoc
    [ assoc>> clear-assoc ] [ dlist>> clear-deque ] bi ;

M: linked-assoc clone
    [ assoc>> clone ] [ dlist>> clone ] bi linked-assoc boa ;

INSTANCE: linked-assoc assoc

{'fraction_non_alphanumeric': 0.1512513601741023, 'fraction_numerical': 0.007254261878853826, 'mean_word_length': 2.9797979797979797, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 75, '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': '3506412', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1048, 'n_words': 282}