<commit_before>"""Implementation of a Deque in Python."""

from dll import DbLinkedList


class Deque(object):
    """Implementation of a deque data structure.

    append(value) adds value to the end of the deque.
    appendleft(value) adds value to the front of the deque.
    pop() removes value from the end of the deque.
    popleft() removes a value from the front of the deque.
    peek() returns the tail value without removing it.
    """

    def __init__(self, iterable=None):
        """Init a deque."""
        self._dblinkedlist = DbLinkedList()
        if iterable and hasattr(iterable, "__iter__"):
            for item in iterable:
                self.append(item)
        elif iterable:
            raise TypeError

    def append(self, value):
        """"""
        self._dblinkedlist.append(value)

    def appendleft(self, value):
        """"""
        self._dblinkedlist.push(value)

    def pop(self):
        """"""
        popped_value = self.shift()
        return popped_value

    # def popleft(self):
    # 	""""""
    # 	popped_value = self.pop()
        # return popped_value

    # def peek(self):
    # 	""""""
    # 	if self._dblinkedlist.head is None:
    # 		return self._dblinkedlist
    # 	return self._dblinkedlist.tail.value

    # def peekleft(self):
    # 	""""""
    # 	return self._dblinkedlist.head.value

    # size(self):
    # 	""""""<commit_msg>more functions. awaiting tests.<commit_after>"""Implementation of a Deque in Python."""

from dll import DbLinkedList


class Deque(object):
    """Implementation of a deque data structure.

    append(value) adds value to the end of the deque.
    appendleft(value) adds value to the front of the deque.
    pop() removes value from the end of the deque.
    popleft() removes a value from the front of the deque.
    peek() returns the tail value without removing it.
    """

    def __init__(self, iterable=None):
        """Init a deque."""
        self._dblinkedlist = DbLinkedList()
        if iterable and hasattr(iterable, "__iter__"):
            for item in iterable:
                self.append(item)
        elif iterable:
            raise TypeError

    def append(self, value):
        """Add value to the end of the deque."""
        self._dblinkedlist.append(value)

    def appendleft(self, value):
        """Add value to the front of the deque."""
        self._dblinkedlist.push(value)

    def pop(self):
        """Remove value from the end of the end of the deque."""
        return self._dblinkedlist.shift()

    def popleft(self):
        """Remove value from the front of the deque."""
        return self._dblinkedlist.pop()

    def peek(self):
        """Return the value of the end of the deque without removing it."""
        if self._dblinkedlist.head is None:
            return self._dblinkedlist
        return self._dblinkedlist.tail.value

    def peekleft(self):
        """Return the value of the front of the deque without removing it."""
        return self._dblinkedlist.head.value

    def size(self):
        """Return the length of the deque."""
        return self._dblinkedlist.length
{'fraction_non_alphanumeric': 0.10571702331523475, 'fraction_numerical': 0.0, 'mean_word_length': 2.3822894168466524, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5470353', 'n_tokens_mistral': 965, 'n_tokens_neox': 932, 'n_words': 307}