def extend(self, values):
_lists = self._lists<EOL>_keys = self._keys<EOL>_maxes = self._maxes<EOL>_load = self._load<EOL>if not isinstance(values, list):<EOL><INDENT>values = list(values)<EOL><DEDENT>keys = list(map(self._key, values))<EOL>if any(keys[pos - <NUM_LIT:1>] > keys[pos]<EOL>for pos in range(<NUM_LIT:1>, len(keys))):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>offset = <NUM_LIT:0><EOL>if _maxes:<EOL><INDENT>if keys[<NUM_LIT:0>] < _keys[-<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(_keys[-<NUM_LIT:1>]) < self._half:<EOL><INDENT>_lists[-<NUM_LIT:1>].extend(values[:_load])<EOL>_keys[-<NUM_LIT:1>].extend(keys[:_load])<EOL>_maxes[-<NUM_LIT:1>] = _keys[-<NUM_LIT:1>][-<NUM_LIT:1>]<EOL>offset = _load<EOL><DEDENT><DEDENT>len_keys = len(_keys)<EOL>for idx in range(offset, len(keys), _load):<EOL><INDENT>_lists.append(values[idx:(idx + _load)])<EOL>_keys.append(keys[idx:(idx + _load)])<EOL>_maxes.append(_keys[-<NUM_LIT:1>][-<NUM_LIT:1>])<EOL><DEDENT>_index = self._index<EOL>if len_keys == len(_keys):<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.