Git Product home page Git Product logo

38-project-ting's Introduction

TING - Trybe is Not Google

GitHub repo size GitHub language count

Projeto de Python para o aprendizado das seguintes estruturas de dados: Hash, Set, Stack, Queue e Linked Lists

Python


Proposta: Criar e utilizar mais estruturas de dados em Python.

Exemplo: Criação de uma estrutura de fila (queue)

class Queue:
    def __init__(self):
        self.data = deque([])
        self.length = 0

    def __len__(self):
        """Retorna o tamanho da lista"""
        return self.length

    def enqueue(self, value):
        """Adiciona item no final da lista"""
        self.data.append(value)
        self.length += 1

    def dequeue(self):
        """Tira um item do começo da lista"""
        self.length -= 1
        return self.data.popleft()

    def search(self, index):
        """Retorna o item no indice passado.
        Se o index for negativo ou vazio, lança um IndexError"""
        if index < 0 or self.data[index] is None:
            raise IndexError
        else:
            return self.data[index]

    def print_lines(self):
        for line in list(self.data):
            print(line)

    def get(self, index):
        return self.data[index]

Criação de uma instância da fila, para processamento de arquivos

def process(path_file, instance):
    """Criar uma instância da fila,
    Armazenar as linhas do arquivo na fila,
    Retornar nome do arquivo, qtd de linhas e as linhas."""

    if len(instance) != 0:
        return None
    instance.enqueue(path_file)

    file_lines = []
    with open(path_file) as file:
        for line in file:
            file_lines.append(line.strip('\n'))

    file_report = {
        "nome_do_arquivo": path_file,
        "qtd_linhas": len(file_lines),
        "linhas_do_arquivo": file_lines
    }
    print(file_report, file=sys.stdout)

Author

👤 Ricardo Rosa

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

38-project-ting's People

Contributors

ricardorosa-dev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.