LLVM 23.0.0git
llvm::ImmutableList< T > Class Template Reference

This class represents an immutable (functional) list. More...

#include "llvm/ADT/ImmutableList.h"

Classes

class  iterator

Public Types

using value_type = T
using Factory = ImmutableListFactory<T>

Public Member Functions

 ImmutableList (const ImmutableListImpl< T > *x=nullptr)
const ImmutableListImpl< T > * getInternalPointer () const
iterator begin () const
 Returns an iterator referring to the head of the list, or an iterator denoting the end of the list if the list is empty.
iterator end () const
 Returns an iterator denoting the end of the list.
bool isEmpty () const
 Returns true if the list is empty.
bool contains (const T &V) const
bool isEqual (const ImmutableList &L) const
 Returns true if two lists are equal.
bool operator== (const ImmutableList &L) const
const TgetHead () const
 Returns the head of the list.
ImmutableList getTail () const
 Returns the tail of the list, which is another (possibly empty) ImmutableList.
void Profile (FoldingSetNodeID &ID) const

Detailed Description

template<typename T>
class llvm::ImmutableList< T >

This class represents an immutable (functional) list.

It is implemented as a smart pointer (wraps ImmutableListImpl), so it is intended to always be copied by value as if it were a pointer. This interface matches ImmutableSet and ImmutableMap. ImmutableList objects should almost never be created directly, and instead should be created by ImmutableListFactory objects that manage the lifetime of a group of lists. When the factory object is reclaimed, all lists created by that factory are released as well.

Definition at line 64 of file ImmutableList.h.

Member Typedef Documentation

◆ Factory

template<typename T>
using llvm::ImmutableList< T >::Factory = ImmutableListFactory<T>

Definition at line 67 of file ImmutableList.h.

◆ value_type

template<typename T>
using llvm::ImmutableList< T >::value_type = T

Definition at line 66 of file ImmutableList.h.

Constructor & Destructor Documentation

◆ ImmutableList()

template<typename T>
llvm::ImmutableList< T >::ImmutableList ( const ImmutableListImpl< T > * x = nullptr)
inline

Member Function Documentation

◆ begin()

template<typename T>
iterator llvm::ImmutableList< T >::begin ( ) const
inline

Returns an iterator referring to the head of the list, or an iterator denoting the end of the list if the list is empty.

Definition at line 105 of file ImmutableList.h.

Referenced by contains().

◆ contains()

template<typename T>
bool llvm::ImmutableList< T >::contains ( const T & V) const
inline

Definition at line 114 of file ImmutableList.h.

References begin(), E(), end(), I, and T.

◆ end()

template<typename T>
iterator llvm::ImmutableList< T >::end ( ) const
inline

Returns an iterator denoting the end of the list.

This iterator does not refer to a valid list element.

Definition at line 109 of file ImmutableList.h.

Referenced by contains().

◆ getHead()

template<typename T>
const T & llvm::ImmutableList< T >::getHead ( ) const
inline

Returns the head of the list.

Definition at line 131 of file ImmutableList.h.

References assert(), isEmpty(), and T.

◆ getInternalPointer()

template<typename T>
const ImmutableListImpl< T > * llvm::ImmutableList< T >::getInternalPointer ( ) const
inline

Definition at line 81 of file ImmutableList.h.

Referenced by llvm::ImmutableList< T >::iterator::iterator().

◆ getTail()

template<typename T>
ImmutableList llvm::ImmutableList< T >::getTail ( ) const
inline

Returns the tail of the list, which is another (possibly empty) ImmutableList.

Definition at line 138 of file ImmutableList.h.

References getTail(), and ImmutableList().

Referenced by getTail().

◆ isEmpty()

template<typename T>
bool llvm::ImmutableList< T >::isEmpty ( ) const
inline

Returns true if the list is empty.

Definition at line 112 of file ImmutableList.h.

Referenced by getHead().

◆ isEqual()

template<typename T>
bool llvm::ImmutableList< T >::isEqual ( const ImmutableList< T > & L) const
inline

Returns true if two lists are equal.

Because all lists created from the same ImmutableListFactory are uniqued, this has O(1) complexity because it the contents of the list do not need to be compared. Note that you should only compare two lists created from the same ImmutableListFactory.

Definition at line 126 of file ImmutableList.h.

References ImmutableList().

Referenced by operator==().

◆ operator==()

template<typename T>
bool llvm::ImmutableList< T >::operator== ( const ImmutableList< T > & L) const
inline

Definition at line 128 of file ImmutableList.h.

References ImmutableList(), and isEqual().

◆ Profile()

template<typename T>
void llvm::ImmutableList< T >::Profile ( FoldingSetNodeID & ID) const
inline

Definition at line 142 of file ImmutableList.h.


The documentation for this class was generated from the following file: