def extend(self, values):
_lists = self._lists<EOL>_maxes = self._maxes<EOL>_load = self._load<EOL>if not isinstance(values, list):<EOL><INDENT>values = list(values)<EOL><DEDENT>if not values:<EOL><INDENT>return<EOL><DEDENT>if any(values[pos - <NUM_LIT:1>] > values[pos]<EOL>for pos in range(<NUM_LIT:1>, len(values))):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>offset = <NUM_LIT:0><EOL>if _maxes:<EOL><INDENT>if values[<NUM_LIT:0>] < _lists[-<NUM_LIT:1>][-<NUM_LIT:1>]:<EOL><INDENT>msg = '<STR_LIT>'.format(values[<NUM_LIT:0>], self._len)<EOL>raise ValueError(msg)<EOL><DEDENT>if len(_lists[-<NUM_LIT:1>]) < self._half:<EOL><INDENT>_lists[-<NUM_LIT:1>].extend(values[:_load])<EOL>_maxes[-<NUM_LIT:1>] = _lists[-<NUM_LIT:1>][-<NUM_LIT:1>]<EOL>offset = _load<EOL><DEDENT><DEDENT>len_lists = len(_lists)<EOL>for idx in range(offset, len(values), _load):<EOL><INDENT>_lists.append(values[idx:(idx + _load)])<EOL>_maxes.append(_lists[-<NUM_LIT:1>][-<NUM_LIT:1>])<EOL><DEDENT>_index = self._index<EOL>if len_lists == len(_lists):<EOL><INDENT>len_index = len(_index)<EOL>if len_index > <NUM_LIT:0>:<EOL><INDENT>len_values = len(values)<EOL>child = len_index - <NUM_LIT:1><EOL>while child:<EOL><INDENT>_index[child] += len_values<EOL>child = (child - <NUM_LIT:1>) >> <NUM_LIT:1><EOL><DEDENT>_index[<NUM_LIT:0>] += len_values<EOL><DEDENT><DEDENT>else:<EOL><INDENT>del _index[:]<EOL><DEDENT>self._len += len(values)<EOL>
Extend the list by appending all elements from the *values*. Raises a
ValueError if the sort order would be violated.