Skip to content

Instantly share code, notes, and snippets.

@stavalfi
Created October 13, 2018 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stavalfi/be7035340da4b314865f1ea5bb73c09c to your computer and use it in GitHub Desktop.
Save stavalfi/be7035340da4b314865f1ea5bb73c09c to your computer and use it in GitHub Desktop.

Introduction

The following exercises are for experimenting and learning Redux. Do not use any external library except rxjs (it's optional and recommended).

Documentations:

Ex1

Write your allocator. Allocate a big block of bytes and manage its allocations and deallocations by your self. For example, allocate an array of 20,000 bytes and divide it into 10 cells such that each cell contains 2,000 bytes. The user can allocate and free cells of 2,000 bytes whenever he wants.

Implement both the following APIs.

API - ( If you are using rxjs)

  1. function allocate(howMuchBlocksToAllocate)
allocator.allocate(2)
          // there will be a next-signal for each allocation
         .subscribe(allocation => console.log(allocation));
  1. function free(allocationId)
allocator.free("myAllocationId")
          // there will be at most one next-signal after you freed the allocation. 
          // if the id represents an already-freed allocation, then there will be only a complet-esignal.
         .subscribe(allocationFreed => console.log(allocationFreed));

API - ( If you are not using rxjs)

  1. function allocate(howMuchBlocksToAllocate,callback)
allocator.allocate(2,allocation => console.log(allocation));
  1. function free(allocationId,callback)
allocator.free("myAllocationId",allocationFreed => console.log(allocationFreed));

Ex2

The following exercise is going to be much more complicated, and its goal is to point about an unsolved problem. Your task is to understand the real problem. To understand it, you are going to implement the solution for the following problem:

-- soon --

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment