Here's the relevant law:
Vehicle Code Section 21801(a): The driver of a vehicle shall yield the right-of-way to any vehicle that is travelling from the opposite direction and is within the intersection or approaching the intersection so closely as to constitute an immediate hazard.
In this case, the other driver was approaching the intersection from the opposite direction and cut in front of your vehicle. This created an immediate hazard, as you had to brake suddenly to avoid a collision. The other driver violated Vehicle Code Section 21801(a) by failing to yield the right-of-way to you.