Class: Rake::LinkedList (Ruby 2.2.4)
Description: Class : Rake::LinkedList - Ruby 2.2.4

- Home
- Core 2.2.4
- Std-lib 2.2.4
- Downloads

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

### Home Classes Methods

### In Files

- rake/linked_list.rb

### Parent

Object

### Namespace

- CLASS Rake::LinkedList::EmptyLinkedList

### Methods

- ::cons
- ::empty
- ::make
- ::new
- #==
- #conj
- #each
- #empty?
- #inspect
- #to_s

### Included Modules

- Enumerable

### Class/Module Index

Quicksearch

- FileUtils
- Module
- Object
- Pathname
- Rake::Application
- Rake::CompositePublisher
- Rake::DSL
- Rake::DefaultLoader
- Rake::EarlyTime
- Rake::FileCreationTask
- Rake::FileList
- Rake::FileTask
- Rake::FileUtilsExt
- Rake::InvocationChain
- Rake::InvocationChain::EmptyInvocationChain
- Rake::InvocationExceptionMixin
- Rake::LateTime
- Rake::LinkedList
- Rake::LinkedList::EmptyLinkedList
- Rake::MakefileLoader
- Rake::MultiTask
- Rake::NameSpace
- Rake::PackageTask
- Rake::PrivateReader
- Rake::RuleRecursionOverflowError
- Rake::Scope
- Rake::SshDirPublisher
- Rake::SshFilePublisher
- Rake::SshFreshDirPublisher
- Rake::Task
- Rake::TaskArgumentError
- Rake::TaskArguments
- Rake::TaskLib
- Rake::TaskManager
- Rake::TestTask
- Rake::Win32
- String

No matching classes.

# Rake::LinkedList

Polylithic linked list structure used to implement several data structures in Rake.

### Constants

EMPTY

### Attributes

head[R]
tail[R]

### Public Class Methods

cons(head, tail) click to toggle source

Cons a new head onto the tail list.

                   # File rake/linked_list.rb, line 70
    def self.cons(head, tail)
      new(head, tail)
    end

empty() click to toggle source

The standard empty list class for the given LinkedList class.

                   # File rake/linked_list.rb, line 75
    def self.empty
      self::EMPTY
    end

make(*args) click to toggle source

Make a list out of the given arguments. This method is polymorphic

                   # File rake/linked_list.rb, line 61
    def self.make(*args)
      result = empty
      args.reverse_each do |item|
        result = cons(item, result)
      end
      result
    end

new(head, tail=EMPTY) click to toggle source

                   # File rake/linked_list.rb, line 10
    def initialize(head, tail=EMPTY)
      @head = head
      @tail = tail
    end

### Public Instance Methods

==(other) click to toggle source

Lists are structurally equivalent.

                   # File rake/linked_list.rb, line 27
    def ==(other)
      current = self
      while ! current.empty? && ! other.empty?
        return false if current.head != other.head
        current = current.tail
        other = other.tail
      end
      current.empty? && other.empty?
    end

conj(item) click to toggle source

Polymorphically add a new element to the head of a list. The type of head node will be the same list type as the tail.

                   # File rake/linked_list.rb, line 17
    def conj(item)
      self.class.cons(item, self)
    end

each() click to toggle source

For each item in the list.

                   # File rake/linked_list.rb, line 50
    def each
      current = self
      while ! current.empty?
        yield(current.head)
        current = current.tail
      end
      self
    end

empty?() click to toggle source

Is the list empty?

                   # File rake/linked_list.rb, line 22
    def empty?
      false
    end

inspect() click to toggle source

Same as `to_s`, but with inspected items.

                   # File rake/linked_list.rb, line 44
    def inspect
      items = map { |item| item.inspect }.join(", ")
      "LL(#{items})"
    end

to_s() click to toggle source

Convert to string: LL(item, item…)

                   # File rake/linked_list.rb, line 38
    def to_s
      items = map { |item| item.to_s }.join(", ")
      "LL(#{items})"
    end