Class: Rinda::TupleBag (Ruby 2.3.2)
Description: Class : Rinda::TupleBag - Ruby 2.3.2

- Home
- Core 2.3.2
- Std-lib 2.3.2
- Downloads

Support for the Ruby 2.3 series has ended. See here for reference.

### Home Classes Methods

### In Files

- rinda/tuplespace.rb

### Parent

Object

### Namespace

- CLASS Rinda::TupleBag::TupleBin

### Methods

- #delete
- #delete_unless_alive
- #find
- #find_all
- #find_all_template
- #has_expires?
- #push

### Class/Module Index

Quicksearch

- Rinda
- Rinda::DRbObjectTemplate
- Rinda::InvalidHashTupleKey
- Rinda::NotifyTemplateEntry
- Rinda::RequestCanceledError
- Rinda::RequestExpiredError
- Rinda::RindaError
- Rinda::RingFinger
- Rinda::RingProvider
- Rinda::RingServer
- Rinda::SimpleRenewer
- Rinda::Template
- Rinda::TemplateEntry
- Rinda::Tuple
- Rinda::TupleBag
- Rinda::TupleBag::TupleBin
- Rinda::TupleEntry
- Rinda::TupleSpace
- Rinda::TupleSpaceProxy
- Rinda::WaitTemplateEntry

No matching classes.

# Rinda::TupleBag

TupleBag is an unordered collection of tuples. It is the basis of Tuplespace.

### Public Instance Methods

delete(tuple) click to toggle source

Removes `tuple` from the TupleBag.

                   # File rinda/tuplespace.rb, line 341
    def delete(tuple)
      key = bin_key(tuple)
      bin = @hash[key]
      return nil unless bin
      bin.delete(tuple)
      @hash.delete(key) if bin.empty?
      tuple
    end

delete_unless_alive() click to toggle source

Delete tuples which dead tuples from the TupleBag, returning the deleted tuples.

                   # File rinda/tuplespace.rb, line 381
    def delete_unless_alive
      deleted = []
      @hash.each do |key, bin|
        bin.delete_if do |tuple|
          if tuple.alive?
            false
          else
            deleted.push(tuple)
            true
          end
        end
      end
      deleted
    end

find(template) click to toggle source

Finds a live tuple that matches `template`.

                   # File rinda/tuplespace.rb, line 361
    def find(template)
      bin_for_find(template).find do |tuple|
        tuple.alive? && template.match(tuple)
      end
    end

find_all(template) click to toggle source

Finds all live tuples that match `template`.

                   # File rinda/tuplespace.rb, line 352
    def find_all(template)
      bin_for_find(template).find_all do |tuple|
        tuple.alive? && template.match(tuple)
      end
    end

find_all_template(tuple) click to toggle source

Finds all tuples in the TupleBag which when treated as templates, match `tuple` and are alive.

                   # File rinda/tuplespace.rb, line 371
    def find_all_template(tuple)
      @enum.find_all do |template|
        template.alive? && template.match(tuple)
      end
    end

has_expires?() click to toggle source

`true` if the TupleBag to see if it has any expired entries.

                   # File rinda/tuplespace.rb, line 323
    def has_expires?
      @enum.find do |tuple|
        tuple.expires
      end
    end

push(tuple) click to toggle source

Add `tuple` to the TupleBag.

                   # File rinda/tuplespace.rb, line 332
    def push(tuple)
      key = bin_key(tuple)
      @hash[key] ||= TupleBin.new
      @hash[key].add(tuple)
    end