/*!
 * Add a \b copy of the \c k first \c chunk at the beginning of the \c linked_list_chunk to it-self.
 * If there is less than \c k \c chunk then no copy is made.
 *
 * For \c k, the following \c linked_list_chunk
 * \verbatim [front]                                     ch0 ch_1 ch_2 ...  ch_k-2 ch_k-1   ch_k ch_k+1 ch_k+2 \endverbatim
 * is transformed into
 * \verbatim [front]  ch0 ch_1 ch_2 ...  ch_k-2 ch_k-1   ch0 ch_1 ch_2 ...  ch_k-2 ch_k-1   ch_k ch_k+1 ch_k+2 \endverbatim
 *
 * \param llc \c linked_list_chunk to add to
 * \param k size of the prefix to copy in front
 * \pre \c llc is valid (assert-ed)
 * \return false if there where less than k element. In such a case, no copy is made.
 */
bool linked_list_chunk_add_self_copy_front ( linked_list_chunk llc ,
        unsigned int k )  {
    inner_linked_chunk* buff = llc->first;
    for(unsigned int i = 0; i<k-1 ; i++) {
        if(buff == NULL) {
            return false;
        }
        buff = buff->suivant;
    }
    for(unsigned int i = 0; i<k; i++) {
        linked_list_chunk_add_front(llc , chunk_copy(buff->value));
        buff = buff->precedent;
    }
    return true;
}
/*!
 * Do various modifications of the  \c linked_list_chunk with the provided \c chunk.
 * On return, the \c chunk is added on both extremities.
 */
static void test_llc_ch ( linked_list_chunk const llc ,
                          chunk const ch ) {

    fprintf ( stdout , "*** adding to back : \"" ) ;
    chunk_print ( ch , stdout ) ;
    fprintf ( stdout , "\" :\n" ) ;
    linked_list_chunk_add_back ( llc , ch ) ;
    linked_list_chunk_print ( llc , stdout ) ;

    fprintf ( stdout , "*** adding to front : \"" ) ;
    chunk_print (  ch , stdout ) ;
    fprintf ( stdout , "\" :\n" ) ;
    linked_list_chunk_add_front ( llc , chunk_copy ( ch ) ) ;
    linked_list_chunk_print ( llc , stdout ) ;

    assert ( ! linked_list_chunk_is_empty ( llc ) ) ;
}