Skip to content

TypeScript-STL v1.1.0

Compare
Choose a tag to compare
@samchon samchon released this 23 Sep 16:41
· 602 commits to master since this release

A minor update v1.1 has released.

New Features

std.for_each_n

  • New feature of C++17

std.base.UniqueMap.extract

  • New feature of C++17.
  • Extract an element (Pair) from a UniqueMap container.
  • Removes an element from a UniqueMap and returns the elemnet.

std.base.UniqueMap.insert_or_assign

  • New feature of C++17
  • Find matched key. If exists, change the mapped value. If not, then inserts the new element.
  • It's same with the base.UniqueMap.set(). I have predicted that such function will be added in C++17, however, failed to predict its name.

std.base.UniqueMap.emplace

In C++ STL, emplace() is a method who calls insert() with new T object, constructed from arguments of varadic template in the emplace(). Using paraeterms in emplace() to creating a new T object, it's possible because the characteristics of C++ template system. Implementing it is not possible in the JavaScript.

However, the map containers, they are storing elements with capsulizing key and mapped value into a std.Pair object. It means that the map containers, their value type is specified exactly (as std.Pair). Thus only the map containers, realizing emplace() is feasible.

template <typename T, typename Alloc = std::allocator<T>, typename Compare = std::less<T>> 
class unordered_set
{
public:
    template <typename ...Args>
    void emplace(Args&&... args)
    {
        // VARADIC TEMPLATE, IT'S ONLY POSSIBLE IN C++
        T &element(args...);
        insert(element);
    }
}

std.base.MultiMap.emplace

  • Same with the std.base.UniqueMap.emplace

std.base.MapContainer.emplace_hint

  • Same with the std.base.UniqueMap.emplace

std.base.UniqueSet.extract

  • Same with the std.base.UniqueMap.extract

std.base.UniqueSet.insert_or_assign

  • Same with the std.base.UniqueMap.insert_or_assign

Fixed Errors

std.Vector.iterator.advance

  • Calling advance() with minus value had ignored.
  • When the iterator is pointing to the Vector.end().

std.Deque.iterator.advance

  • Same with the std.Vector.iterator.advance

std.Deque.erase

  • There had been an error that a Deque is being locked.
  • When only an element was existed in a Deque and the last element is deleted, the last row in the matrix (who is storing Deque's elements in) is also deleted. Thus any row exists in the matrix and it causes any element can be inserted into the Deque.

std.reverse

  • It had not worked at all.

Refactoring

Sorting algorithm on the std.List.sort() has changed.

Until before, std.sort() had subrogated the std.List.sort().

  • Elements in std.List are copied into a new std.Vector
  • After sorting via std.sort(), elements in the std.Vector are assigned the the std.List.
class List<T>
{
    public sort(): void
    {
        // UNTIL BEFORE, STD.SORT HAD SUBROGATED
        let vector: Vector<T> = new Vector<T>(this.begin(), this.end());
        std.sort(vector.begin(), vector.end());

        this.assign(vector.begin(), vector.end());
    }
}

From now on, the sorting is done by std.List itself.

Protected methods are renamed.